Compare commits
282 commits
Author | SHA1 | Date | |
---|---|---|---|
Ludovic Poujol | 3400434f90 | ||
Ludovic Poujol | a7c1af3d83 | ||
Ludovic Poujol | 188e63376d | ||
Ludovic Poujol | a30ba3337b | ||
Ludovic Poujol | b014f1584a | ||
99741826f6 | |||
Mathieu Trossevin | 5a22490dc8 | ||
95108897b0 | |||
Mathieu Trossevin | fd0f03ab05 | ||
whirigoyen | 93c9e450ff | ||
Mathieu Trossevin | 2b6b76b78d | ||
Mathieu Trossevin | 21eef58a96 | ||
Mathieu Trossevin | 6951d1fd33 | ||
0dfb19faea | |||
8e15676d05 | |||
f5fe462248 | |||
964f710897 | |||
c385c102c5 | |||
2fd65724f7 | |||
7d8704cd25 | |||
72e39f297e | |||
2e8619e5e6 | |||
Mathieu Trossevin | 9419242465 | ||
bwaegeneire | e76ea90d89 | ||
a7f718c073 | |||
Ludovic Poujol | f77ce6e590 | ||
Ludovic Poujol | d2365e133b | ||
Ludovic Poujol | fbc48755b0 | ||
Ludovic Poujol | 63dfa3af99 | ||
Ludovic Poujol | 577a4463ad | ||
Ludovic Poujol | 66c159a625 | ||
Ludovic Poujol | 77f5076c88 | ||
ad68e298dd | |||
Ludovic Poujol | 68799f7e5f | ||
Ludovic Poujol | ebb4f1c20c | ||
Ludovic Poujol | f65dd98bb1 | ||
67d0c45d79 | |||
9913579bb0 | |||
e257ee242b | |||
2301b0cba5 | |||
fb78d2a9ed | |||
Ludovic Poujol | 66ceacd918 | ||
Ludovic Poujol | d746aa445e | ||
Ludovic Poujol | 143af65357 | ||
Ludovic Poujol | 96ffc58cc4 | ||
William Hirigoyen (Evolix) | 93629b51fb | ||
d63046b227 | |||
Ludovic Poujol | f2f115608a | ||
Ludovic Poujol | ef5bbbeba7 | ||
William Hirigoyen (Evolix) | d6c39be117 | ||
William Hirigoyen (Evolix) | 5cd6a6f046 | ||
0709747a1e | |||
360929ee96 | |||
e3dc97d6d4 | |||
Ludovic Poujol | ae30498030 | ||
372b00101d | |||
Ludovic Poujol | 7499f0222e | ||
Ludovic Poujol | 4f8b0b19fe | ||
Ludovic Poujol | 2906ba47f1 | ||
Ludovic Poujol | e2acb4e9d1 | ||
Ludovic Poujol | 234ac67634 | ||
Ludovic Poujol | 283d0bccad | ||
Ludovic Poujol | 6438732ea4 | ||
Ludovic Poujol | 9523fff658 | ||
Ludovic Poujol | f7659cee6d | ||
b148cf1176 | |||
3736f7ec32 | |||
a0f41b4b69 | |||
5cd4cff029 | |||
b339ca0fb9 | |||
f3fa182dc7 | |||
4b5a020993 | |||
c5c1648a58 | |||
7d026c907b | |||
283f76540a | |||
c218aebaae | |||
4eaf3ad6d1 | |||
78d0293b44 | |||
27b449fd98 | |||
8fe671097d | |||
839efa6fe9 | |||
37e5ca6484 | |||
9c9ffe1b53 | |||
1b4231e1a9 | |||
1cf62beb55 | |||
3ab7a01077 | |||
c4a6b1f069 | |||
1fc8a3e322 | |||
43318dc09a | |||
3b9a534253 | |||
69936f67db | |||
2737edbc11 | |||
d7f0a5e36c | |||
15faf3dfdc | |||
f6cfe14cdc | |||
bd6d70fbfe | |||
b25639c3aa | |||
320a229d4f | |||
58dda79c6a | |||
4a137ae821 | |||
b44a70f089 | |||
2fff30a658 | |||
6b8128e861 | |||
2193307e14 | |||
4cde233804 | |||
12b907ea63 | |||
4a14333d41 | |||
84a821d58c | |||
634a18d1cb | |||
44b4ac2f5e | |||
a907137e27 | |||
ad452aad6a | |||
b1bab0b40c | |||
5a738c4e2e | |||
1ee7221b19 | |||
1ffa0ef4e7 | |||
bb17afd5fc | |||
6f7fe19046 | |||
ad3c31fb96 | |||
7a0d307f23 | |||
emorino | a3c67afb2a | ||
emorino | c0fb7a5d74 | ||
Ludovic Poujol | a200ccfdeb | ||
Ludovic Poujol | d63150c4ce | ||
Ludovic Poujol | 7b5868db38 | ||
cd6abd008d | |||
Ludovic Poujol | d00ecea964 | ||
c9ed53d7dd | |||
6d0a456de9 | |||
6ef1c9fcf7 | |||
99ac46f671 | |||
fde162d679 | |||
Ludovic Poujol | e0f8d6ade1 | ||
Ludovic Poujol | 2aa7a7a565 | ||
Ludovic Poujol | 1331bb96b4 | ||
Ludovic Poujol | 93608a4147 | ||
Jérémy Lecour | 7faf647185 | ||
Ludovic Poujol | 128db07700 | ||
Ludovic Poujol | 256baadb85 | ||
Ludovic Poujol | 369415b5f5 | ||
d3e5cc7b4c | |||
Ludovic Poujol | 29b92647a7 | ||
Ludovic Poujol | b3ec773c64 | ||
e15e03c36b | |||
fc3fe6bd15 | |||
89858a6bbd | |||
6f0106d4d0 | |||
0bfe7a2aac | |||
2f25655038 | |||
cf4d066f0e | |||
24c4e4236d | |||
bbada41dd5 | |||
4153145c5d | |||
fed8a1fc84 | |||
ce66f0b9b8 | |||
28149ed229 | |||
38308afcf7 | |||
d5f4e27840 | |||
f90b127a95 | |||
20aeb60cda | |||
7e02e50047 | |||
794defa907 | |||
fdce16652a | |||
6e8ea737de | |||
b6fcb25b3b | |||
Ludovic Poujol | 15f4918258 | ||
Benoît S. | 0ae9645f88 | ||
Ludovic Poujol | 34c7c5dc22 | ||
Benoît S. | 9209aae0d1 | ||
Ludovic Poujol | 6b1fa94da9 | ||
Ludovic Poujol | a9b130eaca | ||
Ludovic Poujol | 87c08696e3 | ||
Ludovic Poujol | 468f929d18 | ||
Ludovic Poujol | 501f6ebbab | ||
Ludovic Poujol | 3469dcfcd5 | ||
Ludovic Poujol | 93aeb193ee | ||
Ludovic Poujol | 1641aee38c | ||
Ludovic Poujol | d9dea033a9 | ||
Ludovic Poujol | 7f1af3a8fe | ||
Ludovic Poujol | fe8a1400a5 | ||
Ludovic Poujol | 4005c23772 | ||
Ludovic Poujol | cd9e1af13d | ||
2a183351db | |||
Ludovic Poujol | 52c7cfb888 | ||
b296421022 | |||
Ludovic Poujol | 614de20c34 | ||
Ludovic Poujol | f669c3f793 | ||
b1d602234f | |||
d9bdfe8ff9 | |||
Ludovic Poujol | 1ffd61e967 | ||
2c68341986 | |||
Victor LABORIE | 305c9c0104 | ||
Ludovic Poujol | 249a3ac1e9 | ||
Ludovic Poujol | 2935b771cb | ||
Ludovic Poujol | a52846c977 | ||
Ludovic Poujol | 0cb7c54855 | ||
Ludovic Poujol | 3a19d14e3a | ||
Ludovic Poujol | ead51deca6 | ||
2125055409 | |||
Victor LABORIE | 6ba1fbcb6e | ||
Patrick Marchand | ea359880cc | ||
21f5f011da | |||
Ludovic Poujol | cc08313e1f | ||
Ludovic Poujol | 8429351213 | ||
c135807010 | |||
53335ee4ef | |||
5fe9762c53 | |||
547235ea7e | |||
Patrick Marchand | cade94a7bc | ||
b693075f39 | |||
d64cfa4e8b | |||
Patrick Marchand | a06f31e80a | ||
393851d4c6 | |||
d3be332ba4 | |||
58642ec0ac | |||
2ab5a60906 | |||
66c2c8ab35 | |||
e97ddd8be0 | |||
e3a50177c8 | |||
1e82272487 | |||
Benoît S. | 872f1532d5 | ||
08ef18bc2d | |||
540b7f7278 | |||
e596e3d520 | |||
97bad77040 | |||
05c9525d7e | |||
f4fae90eb1 | |||
5d2d8be5ad | |||
2861d90119 | |||
4aa0332639 | |||
866f20ef47 | |||
3e422bc2bf | |||
Benoît S. | 2125523cd8 | ||
Benoît S. | 45ce021a5c | ||
Victor LABORIE | 353d41a8a6 | ||
Jérémy Lecour | 25d9f7e7d4 | ||
Jérémy Lecour | 637e72743a | ||
Jérémy Lecour | 99ee37b408 | ||
Victor LABORIE | 9ff6846c36 | ||
Ludovic Poujol | 580ff1307e | ||
00e15b32d7 | |||
aaf2316fa5 | |||
75c341fed9 | |||
882c464405 | |||
7e804984d1 | |||
1a2c47986c | |||
ea4d220a59 | |||
53f280096a | |||
5a5063e4cb | |||
5eb619a579 | |||
4a28ee1f53 | |||
a5ceadd1d0 | |||
c166975d46 | |||
0968dbc797 | |||
6b63c02f77 | |||
d27490a49f | |||
Benoît S. | 1bee32dd65 | ||
Benoît S. | 29bbfab45a | ||
623f281628 | |||
483482ab59 | |||
ee8b8a6437 | |||
4dca34f979 | |||
d7bfd75b76 | |||
7ed492470c | |||
c5b6db810f | |||
2947fa2c87 | |||
d16fe6fd70 | |||
4dc9c63cbc | |||
6f3a6ccadd | |||
a5fe856592 | |||
Victor LABORIE | a81be287c4 | ||
Benoît S. | 7a6c625efa | ||
Benoît S. | 77c388d6a6 | ||
58725dcc7c | |||
cada24573d | |||
Benoît S. | f41e64a2b6 | ||
17743c5ba9 | |||
Benoît S. | 0b1c452ee5 | ||
Benoît S. | 68fa678589 | ||
3b7f2f788d | |||
e6edffd820 | |||
Victor LABORIE | 63a2f16b27 |
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
conf/config.local.php
|
||||||
|
.vagrant
|
||||||
|
.idea
|
66
CHANGELOG.md
Normal file
66
CHANGELOG.md
Normal file
|
@ -0,0 +1,66 @@
|
||||||
|
# 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
3
INSTALL
|
@ -1,3 +0,0 @@
|
||||||
* 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
|
|
848
LICENSE
848
LICENSE
|
@ -1,281 +1,620 @@
|
||||||
GNU GENERAL PUBLIC LICENSE
|
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||||
Version 2, June 1991
|
Version 3, 19 November 2007
|
||||||
|
|
||||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
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 licenses for most software are designed to take away your
|
The GNU Affero General Public License is a free, copyleft license for
|
||||||
freedom to share and change it. By contrast, the GNU General Public
|
software and other kinds of works, specifically designed to ensure
|
||||||
License is intended to guarantee your freedom to share and change free
|
cooperation with the community in the case of network server software.
|
||||||
software--to make sure the software is free for all its users. This
|
|
||||||
General Public License applies to most of the Free Software
|
The licenses for most software and other practical works are designed
|
||||||
Foundation's software and to any other program whose authors commit to
|
to take away your freedom to share and change the works. By contrast,
|
||||||
using it. (Some other Free Software Foundation software is covered by
|
our General Public Licenses are intended to guarantee your freedom to
|
||||||
the GNU Lesser General Public License instead.) You can apply it to
|
share and change all versions of a program--to make sure it remains free
|
||||||
your programs, too.
|
software for all its users.
|
||||||
|
|
||||||
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
|
||||||
this service if you wish), that you receive source code or can get it
|
them if you wish), that you receive source code or can get it if you
|
||||||
if you want it, that you can change the software or use pieces of it
|
want it, that you can change the software or use pieces of it in new
|
||||||
in new free programs; and that you know you can do these things.
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
To protect your rights, we need to make restrictions that forbid
|
Developers that use our General Public Licenses protect your rights
|
||||||
anyone to deny you these rights or to ask you to surrender the rights.
|
with two steps: (1) assert copyright on the software, and (2) offer
|
||||||
These restrictions translate to certain responsibilities for you if you
|
you this License which gives you legal permission to copy, distribute
|
||||||
distribute copies of the software, or if you modify it.
|
and/or modify the software.
|
||||||
|
|
||||||
For example, if you distribute copies of such a program, whether
|
A secondary benefit of defending all users' freedom is that
|
||||||
gratis or for a fee, you must give the recipients all the rights that
|
improvements made in alternate versions of the program, if they
|
||||||
you have. You must make sure that they, too, receive or can get the
|
receive widespread use, become available for other developers to
|
||||||
source code. And you must show them these terms so they know their
|
incorporate. Many developers of free software are heartened and
|
||||||
rights.
|
encouraged by the resulting cooperation. However, in the case of
|
||||||
|
software used on network servers, this result may fail to come about.
|
||||||
|
The GNU General Public License permits making a modified version and
|
||||||
|
letting the public access it on a server without ever releasing its
|
||||||
|
source code to the public.
|
||||||
|
|
||||||
We protect your rights with two steps: (1) copyright the software, and
|
The GNU Affero General Public License is designed specifically to
|
||||||
(2) offer you this license which gives you legal permission to copy,
|
ensure that, in such cases, the modified source code becomes available
|
||||||
distribute and/or modify the software.
|
to the community. It requires the operator of a network server to
|
||||||
|
provide the source code of the modified version running there to the
|
||||||
|
users of that server. Therefore, public use of a modified version, on
|
||||||
|
a publicly accessible server, gives the public access to the source
|
||||||
|
code of the modified version.
|
||||||
|
|
||||||
Also, for each author's protection and ours, we want to make certain
|
An older license, called the Affero General Public License and
|
||||||
that everyone understands that there is no warranty for this free
|
published by Affero, was designed to accomplish similar goals. This is
|
||||||
software. If the software is modified by someone else and passed on, we
|
a different license, not a version of the Affero GPL, but Affero has
|
||||||
want its recipients to know that what they have is not the original, so
|
released a new version of the Affero GPL which permits relicensing under
|
||||||
that any problems introduced by others will not reflect on the original
|
this license.
|
||||||
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.
|
||||||
|
|
||||||
GNU GENERAL PUBLIC LICENSE
|
TERMS AND CONDITIONS
|
||||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
|
||||||
|
|
||||||
0. This License applies to any program or other work which contains
|
0. Definitions.
|
||||||
a notice placed by the copyright holder saying it may be distributed
|
|
||||||
under the terms of this General Public License. The "Program", below,
|
|
||||||
refers to any such program or work, and a "work based on the Program"
|
|
||||||
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,
|
|
||||||
either verbatim or with modifications and/or translated into another
|
|
||||||
language. (Hereinafter, translation is included without limitation in
|
|
||||||
the term "modification".) Each licensee is addressed as "you".
|
|
||||||
|
|
||||||
Activities other than copying, distribution and modification are not
|
"This License" refers to version 3 of the GNU Affero General Public License.
|
||||||
covered by this License; they are outside its scope. The act of
|
|
||||||
running the Program is not restricted, and the output from the Program
|
|
||||||
is covered only if its contents constitute a work based on the
|
|
||||||
Program (independent of having been made by running the Program).
|
|
||||||
Whether that is true depends on what the Program does.
|
|
||||||
|
|
||||||
1. You may copy and distribute verbatim copies of the Program's
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
source code as you receive it, in any medium, provided that you
|
works, such as semiconductor masks.
|
||||||
conspicuously and appropriately publish on each copy an appropriate
|
|
||||||
copyright notice and disclaimer of warranty; keep intact all the
|
|
||||||
notices that refer to this License and to the absence of any warranty;
|
|
||||||
and give any other recipients of the Program a copy of this License
|
|
||||||
along with the Program.
|
|
||||||
|
|
||||||
You may charge a fee for the physical act of transferring a copy, and
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
you may at your option offer warranty protection in exchange for a fee.
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
2. You may modify your copy or copies of the Program or any portion
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
of it, thus forming a work based on the Program, and copy and
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
distribute such modifications or work under the terms of Section 1
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
above, provided that you also meet all of these conditions:
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
a) You must cause the modified files to carry prominent notices
|
A "covered work" means either the unmodified Program or a work based
|
||||||
stating that you changed the files and the date of any change.
|
on the Program.
|
||||||
|
|
||||||
b) You must cause any work that you distribute or publish, that in
|
To "propagate" a work means to do anything with it that, without
|
||||||
whole or in part contains or is derived from the Program or any
|
permission, would make you directly or secondarily liable for
|
||||||
part thereof, to be licensed as a whole at no charge to all third
|
infringement under applicable copyright law, except executing it on a
|
||||||
parties under the terms of this License.
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
c) If the modified program normally reads commands interactively
|
To "convey" a work means any kind of propagation that enables other
|
||||||
when run, you must cause it, when started running for such
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
interactive use in the most ordinary way, to print or display an
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
announcement including an appropriate copyright notice and a
|
|
||||||
notice that there is no warranty (or else, saying that you provide
|
|
||||||
a warranty) and that users may redistribute the program under
|
|
||||||
these conditions, and telling the user how to view a copy of this
|
|
||||||
License. (Exception: if the Program itself is interactive but
|
|
||||||
does not normally print such an announcement, your work based on
|
|
||||||
the Program is not required to print an announcement.)
|
|
||||||
|
|
||||||
These requirements apply to the modified work as a whole. If
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
identifiable sections of that work are not derived from the Program,
|
to the extent that it includes a convenient and prominently visible
|
||||||
and can be reasonably considered independent and separate works in
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
themselves, then this License, and its terms, do not apply to those
|
tells the user that there is no warranty for the work (except to the
|
||||||
sections when you distribute them as separate works. But when you
|
extent that warranties are provided), that licensees may convey the
|
||||||
distribute the same sections as part of a whole which is a work based
|
work under this License, and how to view a copy of this License. If
|
||||||
on the Program, the distribution of the whole must be on the terms of
|
the interface presents a list of user commands or options, such as a
|
||||||
this License, whose permissions for other licensees extend to the
|
menu, a prominent item in the list meets this criterion.
|
||||||
entire whole, and thus to each and every part regardless of who wrote it.
|
|
||||||
|
|
||||||
Thus, it is not the intent of this section to claim rights or contest
|
1. Source Code.
|
||||||
your rights to work written entirely by you; rather, the intent is to
|
|
||||||
exercise the right to control the distribution of derivative or
|
|
||||||
collective works based on the Program.
|
|
||||||
|
|
||||||
In addition, mere aggregation of another work not based on the Program
|
The "source code" for a work means the preferred form of the work
|
||||||
with the Program (or with a work based on the Program) on a volume of
|
for making modifications to it. "Object code" means any non-source
|
||||||
a storage or distribution medium does not bring the other work under
|
form of a work.
|
||||||
the scope of this License.
|
|
||||||
|
|
||||||
3. You may copy and distribute the Program (or a work based on it,
|
A "Standard Interface" means an interface that either is an official
|
||||||
under Section 2) in object code or executable form under the terms of
|
standard defined by a recognized standards body, or, in the case of
|
||||||
Sections 1 and 2 above provided that you also do one of the following:
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
a) Accompany it with the complete corresponding machine-readable
|
The "System Libraries" of an executable work include anything, other
|
||||||
source code, which must be distributed under the terms of Sections
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
1 and 2 above on a medium customarily used for software interchange; or,
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
b) Accompany it with a written offer, valid for at least three
|
The "Corresponding Source" for a work in object code form means all
|
||||||
years, to give any third party, for a charge no more than your
|
the source code needed to generate, install, and (for an executable
|
||||||
cost of physically performing source distribution, a complete
|
work) run the object code and to modify the work, including scripts to
|
||||||
machine-readable copy of the corresponding source code, to be
|
control those activities. However, it does not include the work's
|
||||||
distributed under the terms of Sections 1 and 2 above on a medium
|
System Libraries, or general-purpose tools or generally available free
|
||||||
customarily used for software interchange; or,
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
c) Accompany it with the information you received as to the offer
|
The Corresponding Source need not include anything that users
|
||||||
to distribute corresponding source code. (This alternative is
|
can regenerate automatically from other parts of the Corresponding
|
||||||
allowed only for noncommercial distribution and only if you
|
Source.
|
||||||
received the program in object code or executable form with such
|
|
||||||
an offer, in accord with Subsection b above.)
|
|
||||||
|
|
||||||
The source code for a work means the preferred form of the work for
|
The Corresponding Source for a work in source code form is that
|
||||||
making modifications to it. For an executable work, complete source
|
same work.
|
||||||
code means all the source code for all modules it contains, plus any
|
|
||||||
associated interface definition files, plus the scripts used to
|
|
||||||
control compilation and installation of the executable. However, as a
|
|
||||||
special exception, the source code distributed need not include
|
|
||||||
anything that is normally distributed (in either source or binary
|
|
||||||
form) with the major components (compiler, kernel, and so on) of the
|
|
||||||
operating system on which the executable runs, unless that component
|
|
||||||
itself accompanies the executable.
|
|
||||||
|
|
||||||
If distribution of executable or object code is made by offering
|
2. Basic Permissions.
|
||||||
access to copy from a designated place, then offering equivalent
|
|
||||||
access to copy the source code from the same place counts as
|
|
||||||
distribution of the source code, even though third parties are not
|
|
||||||
compelled to copy the source along with the object code.
|
|
||||||
|
|
||||||
4. You may not copy, modify, sublicense, or distribute the Program
|
All rights granted under this License are granted for the term of
|
||||||
except as expressly provided under this License. Any attempt
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
otherwise to copy, modify, sublicense or distribute the Program is
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
void, and will automatically terminate your rights under this License.
|
permission to run the unmodified Program. The output from running a
|
||||||
However, parties who have received copies, or rights, from you under
|
covered work is covered by this License only if the output, given its
|
||||||
this License will not have their licenses terminated so long as such
|
content, constitutes a covered work. This License acknowledges your
|
||||||
parties remain in full compliance.
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
5. You are not required to accept this License, since you have not
|
You may make, run and propagate covered works that you do not
|
||||||
signed it. However, nothing else grants you permission to modify or
|
convey, without conditions so long as your license otherwise remains
|
||||||
distribute the Program or its derivative works. These actions are
|
in force. You may convey covered works to others for the sole purpose
|
||||||
prohibited by law if you do not accept this License. Therefore, by
|
of having them make modifications exclusively for you, or provide you
|
||||||
modifying or distributing the Program (or any work based on the
|
with facilities for running those works, provided that you comply with
|
||||||
Program), you indicate your acceptance of this License to do so, and
|
the terms of this License in conveying all material for which you do
|
||||||
all its terms and conditions for copying, distributing or modifying
|
not control copyright. Those thus making or running the covered works
|
||||||
the Program or works based on it.
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
6. Each time you redistribute the Program (or any work based on the
|
Conveying under any other circumstances is permitted solely under
|
||||||
Program), the recipient automatically receives a license from the
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
original licensor to copy, distribute or modify the Program subject to
|
makes it unnecessary.
|
||||||
these terms and conditions. You may not impose any further
|
|
||||||
restrictions on the recipients' exercise of the rights granted herein.
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
You are not responsible for enforcing compliance by third parties to
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
this License.
|
this License.
|
||||||
|
|
||||||
7. If, as a consequence of a court judgment or allegation of patent
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
infringement or for any other reason (not limited to patent issues),
|
patent license under the contributor's essential patent claims, to
|
||||||
conditions are imposed on you (whether by court order, agreement or
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
otherwise) that contradict the conditions of this License, they do not
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
excuse you from the conditions of this License. If you cannot
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
distribute so as to satisfy simultaneously your obligations under this
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
License and any other pertinent obligations, then as a consequence you
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
may not distribute the Program at all. For example, if a patent
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
license would not permit royalty-free redistribution of the Program by
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
all those who receive copies directly or indirectly through you, then
|
the Program, the only way you could satisfy both those terms and this
|
||||||
the only way you could satisfy both it and this License would be to
|
License would be to refrain entirely from conveying the Program.
|
||||||
refrain entirely from distribution of the Program.
|
|
||||||
|
|
||||||
If any portion of this section is held invalid or unenforceable under
|
13. Remote Network Interaction; Use with the GNU General Public License.
|
||||||
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.
|
|
||||||
|
|
||||||
It is not the purpose of this section to induce you to infringe any
|
Notwithstanding any other provision of this License, if you modify the
|
||||||
patents or other property right claims or to contest validity of any
|
Program, your modified version must prominently offer all users
|
||||||
such claims; this section has the sole purpose of protecting the
|
interacting with it remotely through a computer network (if your version
|
||||||
integrity of the free software distribution system, which is
|
supports such interaction) an opportunity to receive the Corresponding
|
||||||
implemented by public license practices. Many people have made
|
Source of your version by providing access to the Corresponding Source
|
||||||
generous contributions to the wide range of software distributed
|
from a network server at no charge, through some standard or customary
|
||||||
through that system in reliance on consistent application of that
|
means of facilitating copying of software. This Corresponding Source
|
||||||
system; it is up to the author/donor to decide if he or she is willing
|
shall include the Corresponding Source for any work covered by version 3
|
||||||
to distribute software through any other system and a licensee cannot
|
of the GNU General Public License that is incorporated pursuant to the
|
||||||
impose that choice.
|
following paragraph.
|
||||||
|
|
||||||
This section is intended to make thoroughly clear what is believed to
|
Notwithstanding any other provision of this License, you have
|
||||||
be a consequence of the rest of this License.
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the work with which it is combined will remain governed by version
|
||||||
|
3 of the GNU General Public License.
|
||||||
|
|
||||||
8. If the distribution and/or use of the Program is restricted in
|
14. Revised Versions of this License.
|
||||||
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.
|
|
||||||
|
|
||||||
9. The Free Software Foundation may publish revised and/or new versions
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
of the General Public License from time to time. Such new versions will
|
the GNU Affero General Public License from time to time. Such new versions
|
||||||
be similar in spirit to the present version, but may differ in detail to
|
will 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 Program
|
Each version is given a distinguishing version number. If the
|
||||||
specifies a version number of this License which applies to it and "any
|
Program specifies that a certain numbered version of the GNU Affero General
|
||||||
later version", you have the option of following the terms and conditions
|
Public License "or any later version" applies to it, you have the
|
||||||
either of that version or of any later version published by the Free
|
option of following the terms and conditions either of that numbered
|
||||||
Software Foundation. If the Program does not specify a version number of
|
version or of any later version published by the Free Software
|
||||||
this License, you may choose any version ever published by the Free Software
|
Foundation. If the Program does not specify a version number of the
|
||||||
Foundation.
|
GNU Affero General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
10. If you wish to incorporate parts of the Program into other free
|
If the Program specifies that a proxy can decide which future
|
||||||
programs whose distribution conditions are different, write to the author
|
versions of the GNU Affero General Public License can be used, that proxy's
|
||||||
to ask for permission. For software which is copyrighted by the Free
|
public statement of acceptance of a version permanently authorizes you
|
||||||
Software Foundation, write to the Free Software Foundation; we sometimes
|
to choose that version for the Program.
|
||||||
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.
|
|
||||||
|
|
||||||
NO WARRANTY
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
15. Disclaimer of 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.
|
|
||||||
|
|
||||||
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
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
|
||||||
|
|
||||||
|
@ -287,53 +626,36 @@ 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
|
||||||
convey the exclusion of warranty; and each file should have at least
|
state the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
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
|
||||||
|
it under the terms of the GNU Affero General Public License as published by
|
||||||
This program is free software; you can redistribute it and/or modify
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
it under the terms of the GNU General Public License as published by
|
|
||||||
the Free Software Foundation; either version 2 of the License, or
|
|
||||||
(at your option) any later version.
|
(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 General Public License for more details.
|
GNU Affero General Public License for more details.
|
||||||
|
|
||||||
You should have received a copy of the GNU General Public License along
|
You should have received a copy of the GNU Affero General Public License
|
||||||
with this program; if not, write to the Free Software Foundation, Inc.,
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
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 the program is interactive, make it output a short notice like this
|
If your software can interact with users remotely through a computer
|
||||||
when it starts in an interactive mode:
|
network, you should also make sure that it provides a way for users to
|
||||||
|
get its source. For example, if your program is a web application, its
|
||||||
|
interface could display a "Source" link that leads users to an archive
|
||||||
|
of the code. There are many ways you could offer source, and different
|
||||||
|
solutions will be better for different programs; see section 13 for the
|
||||||
|
specific requirements.
|
||||||
|
|
||||||
Gnomovision version 69, Copyright (C) year name of author
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
This is free software, and you are welcome to redistribute it
|
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||||
under certain conditions; type `show c' for details.
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
51
README.md
51
README.md
|
@ -1,3 +1,48 @@
|
||||||
evoadmin-web
|
# Evoadmin-web
|
||||||
============
|
|
||||||
Panel d'administration de serveur web.
|
Web interface and management scripts for web hosting
|
||||||
|
|
||||||
|
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.
|
||||||
|
|
180
README.old.md
Normal file
180
README.old.md
Normal file
|
@ -0,0 +1,180 @@
|
||||||
|
|
||||||
|
### 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
7
TODO
|
@ -1,7 +0,0 @@
|
||||||
* 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
Normal file
38
Vagrantfile
vendored
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
# -*- 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
|
|
@ -1,20 +1,30 @@
|
||||||
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require '../lib/bdd.php';
|
require '../lib/bdd.php';
|
||||||
require_once '../conf/config.php';
|
require_once '../htdocs/common.php';
|
||||||
require_once '../conf/config.local.php';
|
|
||||||
|
|
||||||
|
|
||||||
if ($argc==1) {
|
|
||||||
echo "Specify a server name";
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
$conf = array_merge($oriconf, $localconf);
|
|
||||||
|
|
||||||
$bdd = new bdd();
|
$bdd = new bdd();
|
||||||
|
|
||||||
$file=$conf['cache'];
|
$file = '';
|
||||||
|
$server = '';
|
||||||
|
if (is_mcluster_mode()) {
|
||||||
|
if ($argc != 3) {
|
||||||
|
echo "Multi-cluster mode is enabled in your config file.\n";
|
||||||
|
echo "Usage: $argv[0] <cluster> <server>\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$file = str_replace('%cluster_name%', $argv[1], $conf['cache']);
|
||||||
|
$server = $argv[2];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($argc != 2) {
|
||||||
|
echo "Usage: $argv[0] <server>\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$file = $conf['cache'];
|
||||||
|
$server = $argv[1];
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!file_exists($file)) {
|
if (!file_exists($file)) {
|
||||||
echo "$file doesn't exist\n";
|
echo "$file doesn't exist\n";
|
||||||
|
@ -22,13 +32,8 @@ if (!file_exists($file)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$bdd->open($file);
|
$bdd->open($file);
|
||||||
|
|
||||||
$server = array("name" => $argv[1]);
|
|
||||||
|
|
||||||
$bdd->add_server(array("name" => "$server"));
|
$bdd->add_server(array("name" => "$server"));
|
||||||
exec('ssh -o "UserKnownHostsFile '.$conf['known_host'].'" '.$argv[1].' /bin/true');
|
echo "$server added in $file\n";
|
||||||
|
|
||||||
echo "$server added in cache\n";
|
|
||||||
exit(0);
|
exit(0);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
|
@ -1,28 +1,31 @@
|
||||||
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require '../lib/bdd.php';
|
require '../lib/bdd.php';
|
||||||
require_once '../conf/config.php';
|
require_once '../htdocs/common.php';
|
||||||
require_once '../conf/config.local.php';
|
|
||||||
|
|
||||||
$conf = array_merge($oriconf, $localconf);
|
$files = array();
|
||||||
|
if (is_mcluster_mode()) {
|
||||||
|
foreach ($conf['clusters'] as $cluster) {
|
||||||
$bdd = new bdd();
|
array_push($files, str_replace('%cluster_name%', $cluster, $conf['cache']));
|
||||||
|
}
|
||||||
$file=$conf['cache'];
|
}
|
||||||
|
|
||||||
if (!file_exists($file))
|
|
||||||
$bdd->create($file);
|
|
||||||
else {
|
else {
|
||||||
echo "$file is already created";
|
array_push($files, $conf['cache']);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach ($conf['servers'] as $server) {
|
foreach ($files as $file) {
|
||||||
echo "$server added in cache\n";
|
|
||||||
$bdd->add_server(array("name" => "$server"));
|
$bdd = new bdd();
|
||||||
|
|
||||||
|
if (!file_exists($file)) {
|
||||||
|
$bdd->create($file);
|
||||||
|
echo "$file created.\n";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "$file is already created.\n";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Cache initialisé\n";
|
|
||||||
exit(0);
|
exit(0);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,23 +1,33 @@
|
||||||
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require '../lib/bdd.php';
|
require '../lib/bdd.php';
|
||||||
require_once '../conf/config.php';
|
require_once '../htdocs/common.php';
|
||||||
require_once '../conf/config.local.php';
|
|
||||||
|
|
||||||
$conf = array_merge($oriconf, $localconf);
|
$file = '';
|
||||||
|
$server = '';
|
||||||
|
if (is_mcluster_mode()) {
|
||||||
$bdd = new bdd();
|
if ($argc != 2) {
|
||||||
|
echo "Multi-cluster mode is enabled in your config file.\n";
|
||||||
$file=$conf['cache'];
|
echo "Usage: $argv[0] <cluster>\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$file = str_replace('%cluster_name%', $argv[1], $conf['cache']);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($argc != 1) {
|
||||||
|
echo "Usage: $argv[0]\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
$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->open($file);
|
$bdd->open($file);
|
||||||
|
|
||||||
$domains = $bdd->list_domains();
|
$domains = $bdd->list_domains();
|
||||||
print_r($domains);
|
print_r($domains);
|
||||||
|
|
||||||
|
|
31
conf/config.cluster1.php
Normal file
31
conf/config.cluster1.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configuration page
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009 Evolix - Tous droits reserves
|
||||||
|
*
|
||||||
|
* $Id: config.php 273 2009-05-12 13:54:50Z tmartin $
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
$clusterconf['noreplication'] = array('srv00');
|
||||||
|
$clusterconf['postponedreplication'] = array('srv00', 'srv01', 'srv04');
|
||||||
|
$clusterconf['immediatereplication'] = array('srv00', 'srv01');
|
||||||
|
$clusterconf['postponedreplication_mode'] = array('3 fois/jour', '1 fois/jour', '1 fois/heure');
|
||||||
|
// On specifie des serveurs pour certains modes de replication différés
|
||||||
|
//$clusterconf['1 fois/jour'] = array('srv03', 'srv01');
|
||||||
|
$clusterconf['1 fois/heure'] = array('srv01', 'srv00');
|
||||||
|
|
||||||
|
/* opcodes
|
||||||
|
* type indice array mode
|
||||||
|
|
||||||
|
noreplication 1 x
|
||||||
|
postponedrepl 2 x y m
|
||||||
|
immediaterepl 3 x y
|
||||||
|
*/
|
21
conf/config.cluster2.php
Normal file
21
conf/config.cluster2.php
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Configuration page
|
||||||
|
*
|
||||||
|
* Copyright (c) 2009 Evolix - Tous droits reserves
|
||||||
|
*
|
||||||
|
* $Id: config.php 273 2009-05-12 13:54:50Z tmartin $
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
$clusterconf['noreplication'] = array('srv10');
|
||||||
|
$clusterconf['postponedreplication'] = array('srv10', 'srv11');
|
||||||
|
$clusterconf['immediatereplication'] = array('srv10', 'srv11');
|
||||||
|
$clusterconf['postponedreplication_mode'] = array('3 fois/jour', '1 fois/jour', '1 fois/heure');
|
||||||
|
$clusterconf['1 fois/heure'] = array('srv10', 'srv11');
|
|
@ -15,31 +15,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
// 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';
|
||||||
$localconf['known_host'] = '/home/evoadmin/www/known_host';
|
$oriconf['known_host'] = '/home/evoadmin/www/known_host';
|
||||||
$oriconf['ftpadmin'] = TRUE;
|
$oriconf['ftpadmin'] = false;
|
||||||
|
$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;
|
||||||
|
|
||||||
/* cluster mode
|
$oriconf['noreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com');
|
||||||
* $oriconf['noreplication'] = array('www00');
|
$oriconf['postponedreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com');
|
||||||
* $oriconf['postponedreplication'] = array('www00', 'www01');
|
$oriconf['immediatereplication'] = array('srv00.example.com', 'srv01.example.com');
|
||||||
* $oriconf['immediatereplication'] = array('www00', 'www01');
|
$oriconf['postponedreplication_mode'] = array('1 fois/jour', '3 fois/jour', '1 fois/jour');
|
||||||
* $oriconf['postponedreplication_mode'] = array('3 fois/jour', '1 fois/jour', '1 fois/heure');
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Il est possible de définir pour chaque mode de
|
|
||||||
* postponedreplication_mode une liste de serveurs,
|
|
||||||
* qui seront utilisés à la place des serveurs du
|
|
||||||
* tableau postponedreplication.
|
|
||||||
*
|
|
||||||
* $localconf['1 fois/jour'] = array('www00', 'www01');
|
|
||||||
* $localconf['1 fois/heure'] = array('www01', 'www00');
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
// 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.';
|
||||||
|
|
170
evolibs/Form.php
170
evolibs/Form.php
|
@ -187,8 +187,9 @@ class FormPage {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function addField($name, $obj) {
|
public function addField($name, $obj, $default_value="") {
|
||||||
$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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +374,7 @@ class TextInputFormField extends FormField {
|
||||||
protected $mandatory = NULL;
|
protected $mandatory = NULL;
|
||||||
protected $textsize = NULL;
|
protected $textsize = NULL;
|
||||||
|
|
||||||
public function __construct($label, $mandatory=TRUE, $textsize=array(20, 40)) {
|
public function __construct($label, $mandatory=TRUE, $textsize=array(20, 80)) {
|
||||||
parent::__construct($label);
|
parent::__construct($label);
|
||||||
$this->mandatory = $mandatory;
|
$this->mandatory = $mandatory;
|
||||||
$this->textsize = $textsize;
|
$this->textsize = $textsize;
|
||||||
|
@ -410,6 +411,160 @@ class TextInputFormField extends FormField {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 .= "</p>\n\n";
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class DateInputFormField extends TextInputFormField {
|
class DateInputFormField extends TextInputFormField {
|
||||||
public function __construct($label, $mandatory=TRUE) {
|
public function __construct($label, $mandatory=TRUE) {
|
||||||
parent::__construct($label, $mandatory, array(7, 10));
|
parent::__construct($label, $mandatory, array(7, 10));
|
||||||
|
@ -422,7 +577,7 @@ class DateInputFormField extends TextInputFormField {
|
||||||
if($set_error) $this->error = 'Format de date non valide';
|
if($set_error) $this->error = 'Format de date non valide';
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
$arr_date = split('/', $this->value);
|
$arr_date = explode('/', $this->value);
|
||||||
if(!empty($this->value) &&
|
if(!empty($this->value) &&
|
||||||
!checkdate($arr_date[1],$arr_date[0],$arr_date[2])) {
|
!checkdate($arr_date[1],$arr_date[0],$arr_date[2])) {
|
||||||
if($set_error) $this->error = "La date saisie n'existe pas";
|
if($set_error) $this->error = "La date saisie n'existe pas";
|
||||||
|
@ -565,6 +720,11 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -724,7 +884,7 @@ class SelectFormField extends FormField {
|
||||||
}
|
}
|
||||||
|
|
||||||
public function verify($set_error) {
|
public function verify($set_error) {
|
||||||
if($this->mandatory && empty($this->value)) {
|
if($this->mandatory && strlen($this->value) === 0) {
|
||||||
if($set_error) $this->error = 'Champ obligatoire';
|
if($set_error) $this->error = 'Champ obligatoire';
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -739,7 +899,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) $input.=' selected="selected"';
|
if ($this->value == $value && strlen($this->value) !== 0) $input.=' selected="selected"';
|
||||||
$input .= '>'.$label.'</option>'."\n";
|
$input .= '>'.$label.'</option>'."\n";
|
||||||
}
|
}
|
||||||
$input .= "</select>\n";
|
$input .= "</select>\n";
|
||||||
|
|
BIN
htdocs/img/evolix.gif
Normal file
BIN
htdocs/img/evolix.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 170 B |
BIN
htdocs/img/gmail.gif
Normal file
BIN
htdocs/img/gmail.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 112 B |
|
@ -30,6 +30,10 @@ h1#top {
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h3.form-error {
|
||||||
|
color: red;
|
||||||
|
}
|
||||||
|
|
||||||
div#disclaimer {
|
div#disclaimer {
|
||||||
margin-top: 30px;
|
margin-top: 30px;
|
||||||
}
|
}
|
||||||
|
@ -135,6 +139,11 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -163,4 +172,3 @@ form#form-add legend {
|
||||||
form#form-add p {
|
form#form-add p {
|
||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,6 +21,12 @@ 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');
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,16 +21,16 @@ define('EVOADMIN_BASE','./');
|
||||||
/**
|
/**
|
||||||
* PHP cookies session
|
* PHP cookies session
|
||||||
*/
|
*/
|
||||||
session_name('EVOPMI_SESS');
|
session_name('EVOADMINWEB_SESS');
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
error_reporting(E_ALL | E_NOTICE);
|
error_reporting(E_ALL);
|
||||||
header('Content-Type: text/html; charset=utf-8');
|
header('Content-Type: text/html; charset=utf-8');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requires
|
* Requires
|
||||||
*/
|
*/
|
||||||
require_once EVOADMIN_BASE . 'common.php';
|
require_once EVOADMIN_BASE . '../inc/common.php';
|
||||||
|
|
||||||
|
|
||||||
$uri = $_SERVER['REQUEST_URI'];
|
$uri = $_SERVER['REQUEST_URI'];
|
||||||
|
@ -48,10 +48,47 @@ 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/edit/(.*)/?$#', $uri, $params)) {
|
} elseif (preg_match('#^/webadmin?#', $uri)) {
|
||||||
|
|
||||||
|
// Redirect to /webadmin in order to set $_SESSION['non_stanard']
|
||||||
|
if (!isset($_SESSION['non_standard']))
|
||||||
|
http_redirect('/webadmin');
|
||||||
|
|
||||||
|
// block the non-standard vhost modification
|
||||||
|
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-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';
|
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';
|
||||||
|
@ -64,7 +101,10 @@ 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 !!!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
htdocs/robots.txt
Normal file
2
htdocs/robots.txt
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
User-agent: *
|
||||||
|
Disallow: /
|
142
inc/accounts.php
142
inc/accounts.php
|
@ -15,70 +15,72 @@
|
||||||
|
|
||||||
require_once EVOADMIN_BASE . '../evolibs/Form.php';
|
require_once EVOADMIN_BASE . '../evolibs/Form.php';
|
||||||
require_once EVOADMIN_BASE . '../lib/bdd.php';
|
require_once EVOADMIN_BASE . '../lib/bdd.php';
|
||||||
|
require_once EVOADMIN_BASE . '../lib/domain.php';
|
||||||
|
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
$servers=$conf['servers'];
|
if (is_mcluster_mode()) {
|
||||||
$servers_slave=$conf['servers'];
|
// If the user has not yet selected a cluster, redirect-it to home page.
|
||||||
|
if (empty($_SESSION['cluster'])) {
|
||||||
$servers_slave[]='Aucun';
|
http_redirect('/');
|
||||||
$cache=$conf['cache'];
|
|
||||||
|
|
||||||
|
|
||||||
function domain_add($name, $IP, $with_mxs, $gmail=false) {
|
|
||||||
|
|
||||||
$exec_cmd = 'bind-add-ng.sh';
|
|
||||||
|
|
||||||
if ( $with_mxs == true ) {
|
|
||||||
/* Quai13 specific: use Gmail MXs if wanted */
|
|
||||||
if ( $gmail ) {
|
|
||||||
$exec_cmd .= ' -m ASPMX.L.GOOGLE.com.,10';
|
|
||||||
$exec_cmd .= ' -m ALT1.ASPMX.L.GOOGLE.com.,20';
|
|
||||||
$exec_cmd .= ' -m ALT2.ASPMX.L.GOOGLE.com.,20';
|
|
||||||
$exec_cmd .= ' -m ASPMX2.GOOGLEMAIL.com.,30';
|
|
||||||
$exec_cmd .= ' -m ASPMX3.GOOGLEMAIL.com.,30';
|
|
||||||
}
|
}
|
||||||
else {
|
$cache = str_replace('%cluster_name%', $_SESSION['cluster'], $conf['cache']);
|
||||||
$exec_cmd .= ' -m mail,10';
|
load_config_cluster($_SESSION['cluster']);
|
||||||
$exec_cmd .= ' -m backup.quai13.net.,20';
|
}
|
||||||
}
|
else {
|
||||||
mail($conf['techmail'], '[TAF] Ajouter '.$name.' sur le serveur de mail', wordwrap('Ajouter le domaine '.$name.' à la directive relay_domains dans le fichier /etc/postfix/main.cf sur le serveur mail, pour mettre en place le MX secondaire du domaine.', 70));
|
$cache = $conf['cache'];
|
||||||
}
|
|
||||||
|
|
||||||
$exec_cmd .= " -a $IP $name";
|
|
||||||
|
|
||||||
//echo $exec_cmd."\n";
|
|
||||||
sudoexec($exec_cmd, $exec_output, $exec_return);
|
|
||||||
return array($exec_cmd, $exec_return, $exec_output);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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',
|
||||||
$form->getField('password')->getValue());
|
escapeshellarg($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',
|
||||||
$form->getField('mysql_dbname')->getValue());
|
escapeshellarg($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',
|
||||||
$form->getField('mysql_password')->getValue());
|
escapeshellarg($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,
|
||||||
$form->getField('username')->getValue(),
|
escapeshellarg($form->getField('username')->getValue()),
|
||||||
$form->getField('domain')->getValue());
|
escapeshellarg($form->getField('domain')->getValue()));
|
||||||
|
|
||||||
|
//domain_add($form, $_SERVER['SERVER_ADDR'], true);
|
||||||
sudoexec($exec_cmd, $exec_output, $exec_return);
|
sudoexec($exec_cmd, $exec_output, $exec_return);
|
||||||
|
|
||||||
|
/* Gestion des noms de domaines supplementaires */
|
||||||
|
if ( $form->getField('domain_alias')->getValue() ) {
|
||||||
|
$domain_alias = preg_split('/,/', $form->getField('domain_alias')->getValue());
|
||||||
|
foreach ( $domain_alias as $domain ) {
|
||||||
|
$exec_cmd = 'web-add.sh add-alias '.escapeshellarg($form->getField('username')->getValue()).' ';
|
||||||
|
$domain = trim($domain);
|
||||||
|
$exec_cmd .= $domain.' '. $server_list;
|
||||||
|
sudoexec($exec_cmd, $exec_output, $exec_return);
|
||||||
|
}
|
||||||
|
$exec_return |= $exec_return2; // $exec_return == 0 if $exec_return == 0 && $exec_return2 == 0
|
||||||
|
array_push($exec_output, $exec_output2);
|
||||||
|
}
|
||||||
|
|
||||||
return array($exec_cmd, $exec_return, $exec_output);
|
return array($exec_cmd, $exec_return, $exec_output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,17 +97,17 @@ function web_add_cluster($form, $admin_mail) {
|
||||||
|
|
||||||
if(!$form->getField('password_random')->getValue()) {
|
if(!$form->getField('password_random')->getValue()) {
|
||||||
$exec_cmd .= sprintf(' -p %s',
|
$exec_cmd .= sprintf(' -p %s',
|
||||||
$form->getField('password')->getValue());
|
escapeshellarg($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',
|
||||||
$form->getField('mysql_dbname')->getValue());
|
escapeshellarg($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',
|
||||||
$form->getField('mysql_password')->getValue());
|
escapeshellarg($form->getField('mysql_password')->getValue()));
|
||||||
}
|
}
|
||||||
|
|
||||||
$account['bdd'] = $form->getField('mysql_dbname')->getValue();
|
$account['bdd'] = $form->getField('mysql_dbname')->getValue();
|
||||||
|
@ -172,13 +174,14 @@ function web_add_cluster($form, $admin_mail) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$exec_cmd .= sprintf(' -l %s %s %s %s %s %s 2>&1',
|
$exec_cmd .= sprintf(' -l %s %s %s %s %s %s 2>&1',
|
||||||
$admin_mail,
|
escapeshellarg($admin_mail),
|
||||||
$form->getField('username')->getValue(),
|
escapeshellarg($form->getField('username')->getValue()),
|
||||||
$form->getField('domain')->getValue(),
|
escapeshellarg($form->getField('domain')->getValue()),
|
||||||
$master,
|
escapeshellarg($master),
|
||||||
$slave,
|
escapeshellarg($slave),
|
||||||
($realtime ? 'realtime': 'deferred'));
|
escapeshellarg( ($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);
|
||||||
|
|
||||||
|
@ -186,7 +189,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 '.$form->getField('username')->getValue().' ';
|
$exec_cmd = 'web-add-cluster.sh add-alias '.escapeshellarg($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);
|
||||||
|
@ -205,6 +208,11 @@ function web_add_cluster($form, $admin_mail) {
|
||||||
|
|
||||||
$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())
|
||||||
|
$account['mail'] = 'gmail';
|
||||||
|
else
|
||||||
|
$account['mail'] = 'evolix';
|
||||||
|
|
||||||
$bdd->add_account($account);
|
$bdd->add_account($account);
|
||||||
|
|
||||||
|
@ -242,9 +250,9 @@ 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 TextInputFormField("Nom d'utilisateur", TRUE));
|
$form->addField('username', new AlphaNumericalTextInputFormField("Nom d'utilisateur", TRUE, array(20,16)));
|
||||||
$form->addField('domain', new TextInputFormField("Nom de domaine", TRUE));
|
$form->addField('domain', new DomainInputFormField("Nom de domaine", TRUE));
|
||||||
$form->addField('domain_alias', new TextInputFormField("Alias (séparés par une virgule)", FALSE));
|
$form->addField('domain_alias', new DomainListInputFormField("Alias (séparés par une virgule, sans espaces)", 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);
|
||||||
|
@ -255,13 +263,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 TextInputFormField("Nom de la base MySQL", FALSE));
|
new AlphaNumericalTextInputFormField("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();
|
||||||
|
@ -334,8 +342,23 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Quai13 specific: allow to switch between Gmail MX/Quai13 MX */
|
if ($conf['bindadmin']) {
|
||||||
$form->addField('use_gmail_mxs', new CheckboxInputFormField("Utilisation des serveurs Gmail en MX ?", FALSE));
|
/* Quai13 specific: allow to switch between Gmail MX/Quai13 MX */
|
||||||
|
$form->addField('use_gmail_mxs', new CheckboxInputFormField("Utilisation des serveurs Gmail en MX ?", 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)) {
|
||||||
|
@ -365,11 +388,22 @@ if(!empty($_POST)) {
|
||||||
|
|
||||||
/* Test de validation du formulaire */
|
/* Test de validation du formulaire */
|
||||||
if($form->verify(TRUE)) {
|
if($form->verify(TRUE)) {
|
||||||
|
$errors_check = array();
|
||||||
|
|
||||||
|
if(check_occurence_name($form->getField('domain')->getValue())){
|
||||||
|
array_push($errors_check, "Domaine déjà présent dans d'autres vhosts.");
|
||||||
|
}
|
||||||
|
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'])
|
if ($conf['cluster'])
|
||||||
$exec_info = web_add_cluster($form, $conf['admin']['mail']);
|
$exec_info = web_add_cluster($form, $conf['admin']['mail']);
|
||||||
else
|
else
|
||||||
$exec_info = web_add($form, $conf['admin']['mail']);
|
$exec_info = web_add($form, $conf['admin']['mail']);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
||||||
|
|
60
inc/auth.php
60
inc/auth.php
|
@ -1,57 +1,53 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authentification page
|
* Authentification controler
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009 Evolix - Tous droits reserves
|
* Copyright (c) 2009-2022 Evolix - Tous droits reserves
|
||||||
*
|
|
||||||
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
|
|
||||||
*
|
*
|
||||||
|
* @author Evolix <info@evolix.fr>
|
||||||
* @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>
|
||||||
|
* @author and others.
|
||||||
* @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']);
|
||||||
|
|
||||||
if ((empty($_GET['form']) || $_GET['form']!=1) && !empty($_POST)) {
|
} elseif (isset($conf['logins'][$input_username]) && strlen($conf['logins'][$input_username]) == 64 && hash("sha256",$input_password) === $conf['logins'][$input_username]) {
|
||||||
$login=0;
|
// Compatibility mode for previous installs (sha256)
|
||||||
$username=$_POST['login'];
|
$_SESSION['auth'] = true;
|
||||||
$password=$_POST['passw'];
|
$_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']);
|
||||||
|
|
||||||
|
|
||||||
$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 = split(',',$user['gecos']);
|
|
||||||
$user['gecos'] = $gecos[0];
|
|
||||||
$_SESSION['user_id'] = $user['uid'];
|
|
||||||
$_SESSION['user_gid'] = $user['gid'];
|
|
||||||
$_SESSION['user_name'] = $user['gecos'];
|
|
||||||
} else {
|
} else {
|
||||||
$_SESSION['auth']=0;
|
$_SESSION['auth'] = false;
|
||||||
$_SESSION['user']='';
|
$_SESSION['user'] = '';
|
||||||
$_SESSION['error']=1;
|
$_SESSION['error'] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
http_redirect('/');
|
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';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* file included in every PHP file
|
* file included in every PHP file
|
||||||
*
|
*
|
||||||
|
@ -27,14 +26,14 @@ function test_exist($file) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function http_redirect($path) {
|
function http_redirect($path) {
|
||||||
header('Location: http://'.$_SERVER['HTTP_HOST'].$path);
|
header('Location: '.$_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$path);
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function findexts ($filename)
|
function findexts ($filename)
|
||||||
{
|
{
|
||||||
$filename = strtolower($filename) ;
|
$filename = strtolower($filename) ;
|
||||||
$exts = split("[/\\.]", $filename) ;
|
$exts = explode("[/\\.]", $filename) ;
|
||||||
$n = count($exts)-1;
|
$n = count($exts)-1;
|
||||||
$exts = $exts[$n];
|
$exts = $exts[$n];
|
||||||
return $exts;
|
return $exts;
|
||||||
|
@ -60,6 +59,62 @@ function sudoexec($cmd, &$output, &$return_var) {
|
||||||
exec($cmd, $output, $return_var);
|
exec($cmd, $output, $return_var);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return TRUE is Evoadmin is installed in cluster mode.
|
||||||
|
*/
|
||||||
|
function is_cluster_mode() {
|
||||||
|
global $conf;
|
||||||
|
return $conf['cluster'];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return TRUE is Evoadmin is installed in multi-cluster mode.
|
||||||
|
*/
|
||||||
|
function is_mcluster_mode() {
|
||||||
|
global $conf;
|
||||||
|
return is_cluster_mode() && array_key_exists('clusters', $conf) && is_array($conf['clusters']);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load config file for the specified cluster.
|
||||||
|
*/
|
||||||
|
function load_config_cluster($cluster) {
|
||||||
|
global $conf;
|
||||||
|
$configfile = '../conf/config.'.$cluster.'.php';
|
||||||
|
test_exist($configfile);
|
||||||
|
require_once($configfile);
|
||||||
|
$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
|
||||||
*/
|
*/
|
||||||
|
@ -80,8 +135,5 @@ 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);
|
||||||
}
|
}
|
||||||
|
|
45
inc/dbadmin.php
Normal file
45
inc/dbadmin.php
Normal file
|
@ -0,0 +1,45 @@
|
||||||
|
<?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';
|
||||||
|
?>
|
|
@ -155,7 +155,7 @@ if ($action=="add") {
|
||||||
|
|
||||||
} elseif ($action=="delete") {
|
} elseif ($action=="delete") {
|
||||||
|
|
||||||
sudoexec("ftpadmin.sh -a d -u $user_id -n $account -f /dev/null -p azertyuiop", $standard_output, $function_output);
|
sudoexec("ftpadmin.sh -a d -n $account -f /dev/null -p azertyuiop", $standard_output, $function_output);
|
||||||
|
|
||||||
|
|
||||||
$_SESSION['error'] = null;
|
$_SESSION['error'] = null;
|
||||||
|
@ -182,14 +182,14 @@ if ($action=="add") {
|
||||||
|
|
||||||
foreach ($account_list as $account) {
|
foreach ($account_list as $account) {
|
||||||
|
|
||||||
$infos = split(':', $account);
|
$infos = explode(':', $account);
|
||||||
|
|
||||||
|
|
||||||
if (!empty($infos[0])) {
|
if (!empty($infos[0])) {
|
||||||
$table[$num_line]['owner'] = $infos[0];
|
$table[$num_line]['owner'] = $infos[0];
|
||||||
$table[$num_line]['name'] = $infos[1];
|
$table[$num_line]['name'] = $infos[1];
|
||||||
|
|
||||||
$path = split("/", $infos[2]);
|
$path = explode("/", $infos[2]);
|
||||||
$rel_path='';
|
$rel_path='';
|
||||||
foreach($path as $id => $folder) {
|
foreach($path as $id => $folder) {
|
||||||
if ($id>2) $rel_path.='/'.$folder;
|
if ($id>2) $rel_path.='/'.$folder;
|
||||||
|
@ -256,6 +256,7 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
16
inc/home.php
16
inc/home.php
|
@ -13,6 +13,22 @@
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once EVOADMIN_BASE . '../evolibs/Form.php';
|
||||||
|
|
||||||
|
if (is_mcluster_mode()) {
|
||||||
|
$form = new FormPage("Sélection du cluster", FALSE);
|
||||||
|
$form->addField('cluster_name', new SelectFormField('cluster', FALSE, $conf['clusters']));
|
||||||
|
|
||||||
|
if (!empty($_POST)) {
|
||||||
|
$form->isCurrentPage(TRUE);
|
||||||
|
$form->initFields();
|
||||||
|
|
||||||
|
if ($form->verify(TRUE)) {
|
||||||
|
$_SESSION['cluster'] = $form->getField('cluster_name')->getReadableValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
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/home.tpl.php';
|
include_once EVOADMIN_BASE . '../tpl/home.tpl.php';
|
||||||
|
|
72
inc/webadmin-delete.php
Normal file
72
inc/webadmin-delete.php
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
<?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';
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -14,76 +14,46 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require_once EVOADMIN_BASE . '../lib/bdd.php';
|
require_once EVOADMIN_BASE . '../lib/bdd.php';
|
||||||
|
require_once EVOADMIN_BASE . '../lib/domain.php';
|
||||||
|
|
||||||
global $conf;
|
global $conf;
|
||||||
|
|
||||||
if (isset($_GET['del']) ) {
|
$redirect_url = "/webadmin/" . $params[1] . "/alias/";
|
||||||
|
|
||||||
|
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 = htmlspecialchars($_GET['del']);
|
$alias = $params[3];
|
||||||
|
|
||||||
if (isset($_GET['modif']) && ($_GET['modif'] == 'yes')) {
|
if (isset($_POST["confirm-delete-alias"])) {
|
||||||
|
|
||||||
print "<center>";
|
print "<center>";
|
||||||
print "<p>Suppression de $alias...</p>";
|
print "<p>Suppression de $alias...</p>";
|
||||||
|
|
||||||
|
|
||||||
$serveralias = array (
|
$serveralias = array (
|
||||||
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_SCRIPT_URL'])),
|
'domain' => $params[1],
|
||||||
'alias' => $alias
|
'alias' => $alias
|
||||||
);
|
);
|
||||||
|
|
||||||
if ($conf['cluster']) {
|
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'];
|
$cache = $conf['cache'];
|
||||||
|
}
|
||||||
$bdd = new bdd();
|
$bdd = new bdd();
|
||||||
$bdd->open($cache);
|
$bdd->open($cache);
|
||||||
|
|
||||||
if (! $bdd->del_serveralias($serveralias))
|
|
||||||
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
|
|
||||||
}
|
|
||||||
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $_SERVER['REDIRECT_SCRIPT_URL']);
|
|
||||||
print "</center>";
|
|
||||||
|
|
||||||
} else if ( ! isset($_GET['modif']) ) {
|
|
||||||
|
|
||||||
print "<center>";
|
|
||||||
print "<p>Confirmez vous la suppression de $alias ?</p>";
|
|
||||||
printf ('<p><a href="%s?del=%s&modif=yes">Confirmer la suppression</a></p>', $_SERVER['REDIRECT_SCRIPT_URL'], $alias);
|
|
||||||
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $_SERVER['REDIRECT_SCRIPT_URL']);
|
|
||||||
print "</center>";
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
|
||||||
|
|
||||||
} else if (isset($_GET['add']) ) {
|
|
||||||
|
|
||||||
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("Ajout d'un alias", FALSE);
|
|
||||||
$form->addField('domain_alias', new TextInputFormField("Alias", FALSE));
|
|
||||||
|
|
||||||
if (!empty($_POST)) {
|
|
||||||
$form->isCurrentPage(TRUE);
|
|
||||||
$form->initFields();
|
|
||||||
|
|
||||||
if ($form->verify(TRUE)) {
|
|
||||||
if ($conf['cluster']) {
|
|
||||||
$cache = $conf['cache'];
|
|
||||||
$bdd = new bdd();
|
|
||||||
$bdd->open($cache);
|
|
||||||
|
|
||||||
$serveralias = array (
|
|
||||||
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_SCRIPT_URL'])),
|
|
||||||
'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);
|
||||||
|
|
||||||
|
@ -93,16 +63,96 @@ if (isset($_GET['del']) ) {
|
||||||
$master = $bdd->get_server_from_roleid($account['id_master']);
|
$master = $bdd->get_server_from_roleid($account['id_master']);
|
||||||
$slave = $bdd->get_server_from_roleid($account['id_slave']);
|
$slave = $bdd->get_server_from_roleid($account['id_slave']);
|
||||||
|
|
||||||
|
/* web-add-cluster addalias */
|
||||||
|
$exec_cmd = 'web-add-cluster.sh del-alias '.$serveralias['domain'].' '.$serveralias['alias'].' '.$master.' '.$slave;
|
||||||
|
sudoexec($exec_cmd, $exec_output, $exec_return);
|
||||||
|
|
||||||
|
if ($exec_return == 0) {
|
||||||
|
if (! $bdd->del_serveralias($serveralias))
|
||||||
|
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
|
||||||
|
printf ('<p>Alias %s est supprimé.</p>', $serveralias['alias']);
|
||||||
|
} else
|
||||||
|
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$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>";
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
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><input type=\"hidden\" name=\"confirm-delete-alias\" value=\"confirm\">";
|
||||||
|
print " <p><input type=\"submit\" value=\"Confirmer la suppression\"/ style=\"margin-left:0px;\"></p>";
|
||||||
|
print "</form>";
|
||||||
|
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $redirect_url);
|
||||||
|
print "</center>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
||||||
|
}
|
||||||
|
elseif (isset($params[2]) && $params[2] == "add") {
|
||||||
|
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("Ajout d'un alias", FALSE);
|
||||||
|
$form->addField('domain_alias', new DomainInputFormField("Alias", TRUE));
|
||||||
|
|
||||||
|
if (!empty($_POST)) {
|
||||||
|
$form->isCurrentPage(TRUE);
|
||||||
|
$form->initFields();
|
||||||
|
|
||||||
|
if ($form->verify(TRUE)) {
|
||||||
|
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);
|
||||||
|
|
||||||
|
$serveralias = array (
|
||||||
|
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_URL'])),
|
||||||
|
'alias' => $form->getField('domain_alias')->getValue(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$account_name=$serveralias['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 */
|
/* web-add-cluster addalias */
|
||||||
$exec_cmd = 'web-add-cluster.sh add-alias '.$serveralias['domain'].' '.$serveralias['alias'].' '.$master.' '.$slave;
|
$exec_cmd = 'web-add-cluster.sh add-alias '.$serveralias['domain'].' '.$serveralias['alias'].' '.$master.' '.$slave;
|
||||||
sudoexec($exec_cmd, $exec_output, $exec_return);
|
sudoexec($exec_cmd, $exec_output, $exec_return);
|
||||||
|
|
||||||
/* bind add */
|
|
||||||
$exec_cmd = 'bind-add-ng.sh';
|
|
||||||
$exec_cmd .= ' -a '. gethostbyname($master) .' '.$serveralias['alias'];
|
|
||||||
sudoexec($exec_cmd, $exec_output, $exec_return2);
|
|
||||||
|
|
||||||
$exec_return |= $exec_return2;
|
|
||||||
|
|
||||||
if ($exec_return == 0) {
|
if ($exec_return == 0) {
|
||||||
/* Ajout BDD */
|
/* Ajout BDD */
|
||||||
|
@ -119,21 +169,74 @@ if (isset($_GET['del']) ) {
|
||||||
|
|
||||||
print "<center>";
|
print "<center>";
|
||||||
printf ('<p>L\'alias %s du domaine %s a bien été créé</p>', $serveralias['alias'], $serveralias['domain']);
|
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>', $_SERVER['REDIRECT_SCRIPT_URL']);
|
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $_SERVER['REDIRECT_URL']);
|
||||||
print "</center>";
|
print "</center>";
|
||||||
} else {
|
} else {
|
||||||
print "<center>";
|
print "<center>";
|
||||||
printf ('<p>Echec dans la creation de l\'alias %s du domaine %s</p>', $serveralias['alias'], $serveralias['domain']);
|
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>', $_SERVER['REDIRECT_SCRIPT_URL']);
|
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $_SERVER['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>', $_SERVER['REDIRECT_URL']);
|
||||||
|
print "</center>";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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>";
|
print "</center>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} 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 serveralias</legend>";
|
print " <legend>Ajout d'un alias</legend>";
|
||||||
|
print $form;
|
||||||
|
print " <p><input type=\"submit\" value=\"Créer\"/></p>";
|
||||||
|
print " </fieldset>";
|
||||||
|
print "</form>";
|
||||||
|
|
||||||
|
}
|
||||||
|
} 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 $form;
|
||||||
print " <p><input type=\"submit\" value=\"Créer\"/></p>";
|
print " <p><input type=\"submit\" value=\"Créer\"/></p>";
|
||||||
print " </fieldset>";
|
print " </fieldset>";
|
||||||
|
@ -142,16 +245,24 @@ if (isset($_GET['del']) ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
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();
|
||||||
|
|
||||||
if ($conf['cluster']) {
|
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'];
|
$cache = $conf['cache'];
|
||||||
|
}
|
||||||
|
|
||||||
$alias_list = array();
|
$alias_list = array();
|
||||||
|
|
||||||
|
@ -161,6 +272,26 @@ if (isset($_GET['del']) ) {
|
||||||
|
|
||||||
$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';
|
||||||
|
|
94
inc/webadmin-itk.php
Normal file
94
inc/webadmin-itk.php
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
<?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';
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
168
inc/webadmin-letsencrypt.php
Normal file
168
inc/webadmin-letsencrypt.php
Normal file
|
@ -0,0 +1,168 @@
|
||||||
|
<?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';
|
94
inc/webadmin-php.php
Normal file
94
inc/webadmin-php.php
Normal file
|
@ -0,0 +1,94 @@
|
||||||
|
<?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';
|
||||||
|
}
|
218
inc/webadmin-servername.php
Normal file
218
inc/webadmin-servername.php
Normal file
|
@ -0,0 +1,218 @@
|
||||||
|
<?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';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
198
inc/webadmin-suppr.php
Executable file
198
inc/webadmin-suppr.php
Executable file
|
@ -0,0 +1,198 @@
|
||||||
|
<?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($_GET['del']) ) {
|
||||||
|
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
|
||||||
|
|
||||||
|
$alias = htmlspecialchars($_GET['del']);
|
||||||
|
|
||||||
|
if (isset($_GET['modif']) && ($_GET['modif'] == 'yes')) {
|
||||||
|
|
||||||
|
print "<center>";
|
||||||
|
print "<p>Suppression de $alias...</p>";
|
||||||
|
|
||||||
|
|
||||||
|
$serveralias = array (
|
||||||
|
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_SCRIPT_URL'])),
|
||||||
|
'alias' => $alias
|
||||||
|
);
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
$account_name=$serveralias['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']);
|
||||||
|
|
||||||
|
/* web-add-cluster addalias */
|
||||||
|
$exec_cmd = 'web-add-cluster.sh del-alias '.$serveralias['domain'].' '.$serveralias['alias'].' '.$master.' '.$slave;
|
||||||
|
sudoexec($exec_cmd, $exec_output, $exec_return);
|
||||||
|
|
||||||
|
if ($exec_return == 0) {
|
||||||
|
if (! $bdd->del_serveralias($serveralias))
|
||||||
|
print "<p>La suppression a échouée. Veuillez contacter votre administrateur.</p>";
|
||||||
|
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>', $_SERVER['REDIRECT_SCRIPT_URL']);
|
||||||
|
print "</center>";
|
||||||
|
|
||||||
|
} else if ( ! isset($_GET['modif']) ) {
|
||||||
|
|
||||||
|
print "<center>";
|
||||||
|
print "<p>Confirmez vous la suppression de $alias ?</p>";
|
||||||
|
printf ('<p><a href="%s?del=%s&modif=yes">Confirmer la suppression</a></p>', $_SERVER['REDIRECT_SCRIPT_URL'], $alias);
|
||||||
|
printf ('<p><a href="%s">Retour à la liste des alias</a></p>', $_SERVER['REDIRECT_SCRIPT_URL']);
|
||||||
|
print "</center>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
||||||
|
|
||||||
|
} else if (isset($_GET['add']) ) {
|
||||||
|
|
||||||
|
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("Ajout d'un alias", FALSE);
|
||||||
|
$form->addField('domain_alias', new TextInputFormField("Alias", FALSE));
|
||||||
|
|
||||||
|
if (!empty($_POST)) {
|
||||||
|
$form->isCurrentPage(TRUE);
|
||||||
|
$form->initFields();
|
||||||
|
|
||||||
|
if ($form->verify(TRUE)) {
|
||||||
|
if ($conf['cluster']) {
|
||||||
|
$cache = $conf['cache'];
|
||||||
|
$bdd = new bdd();
|
||||||
|
$bdd->open($cache);
|
||||||
|
|
||||||
|
$serveralias = array (
|
||||||
|
'domain' => htmlspecialchars(basename($_SERVER['REDIRECT_SCRIPT_URL'])),
|
||||||
|
'alias' => $form->getField('domain_alias')->getValue(),
|
||||||
|
);
|
||||||
|
|
||||||
|
$account_name=$serveralias['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);
|
||||||
|
|
||||||
|
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>', $_SERVER['REDIRECT_SCRIPT_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>', $_SERVER['REDIRECT_SCRIPT_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>', $_SERVER['REDIRECT_SCRIPT_URL']);
|
||||||
|
print "</center>";
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
|
||||||
|
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
|
||||||
|
print " <fieldset>";
|
||||||
|
print " <legend>Ajout d'un serveralias</legend>";
|
||||||
|
print $form;
|
||||||
|
print " <p><input type=\"submit\" value=\"Créer\"/></p>";
|
||||||
|
print " </fieldset>";
|
||||||
|
print "</form>";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
||||||
|
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$domain = $params[1];
|
||||||
|
$alias_list = array();
|
||||||
|
|
||||||
|
if ($conf['cluster']) {
|
||||||
|
|
||||||
|
$cache = $conf['cache'];
|
||||||
|
|
||||||
|
$alias_list = array();
|
||||||
|
|
||||||
|
/* parcours de la table Serveralias */
|
||||||
|
$bdd = new bdd();
|
||||||
|
$bdd->open($cache);
|
||||||
|
|
||||||
|
$alias_list = $bdd->list_serveralias($domain);
|
||||||
|
}
|
||||||
|
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/menu.tpl.php';
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/webadmin-edit.tpl.php';
|
||||||
|
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
|
@ -22,6 +22,7 @@ global $conf;
|
||||||
if (!$conf['cluster']) {
|
if (!$conf['cluster']) {
|
||||||
|
|
||||||
$cmd = 'web-add.sh list-vhost';
|
$cmd = 'web-add.sh list-vhost';
|
||||||
|
|
||||||
if(!is_superadmin()) {
|
if(!is_superadmin()) {
|
||||||
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']);
|
$cmd = sprintf('%s %s', $cmd, $_SESSION['user']);
|
||||||
}
|
}
|
||||||
|
@ -29,20 +30,85 @@ if (!$conf['cluster']) {
|
||||||
|
|
||||||
/* Récupération de cette liste dans le tableau $vhost_list */
|
/* Récupération de cette liste dans le tableau $vhost_list */
|
||||||
$vhost_list = array();
|
$vhost_list = array();
|
||||||
|
|
||||||
|
if (!isset($_SESSION['non_standard'])) {
|
||||||
|
$_SESSION['non_standard'] = array();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
foreach($data_output as $data_line) {
|
foreach($data_output as $data_line) {
|
||||||
$data_split = split(':', $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(
|
array_push($vhost_list, array(
|
||||||
'owner' => $data_split[0],
|
'owner' => $data_split[0],
|
||||||
'configid' => $data_split[1],
|
'configid' => $data_split[1],
|
||||||
'server_name' => $data_split[2],
|
'server_name' => $data_split[2],
|
||||||
'server_alias' => $data_split[3])
|
'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 {
|
||||||
|
|
||||||
$cache=$conf['cache'];
|
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'];
|
||||||
|
}
|
||||||
|
|
||||||
$vhost_list = array();
|
$vhost_list = array();
|
||||||
|
|
||||||
|
@ -54,7 +120,6 @@ else {
|
||||||
|
|
||||||
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 = '';
|
$slave = '';
|
||||||
|
@ -65,14 +130,13 @@ else {
|
||||||
'owner' => $account['name'],
|
'owner' => $account['name'],
|
||||||
'server_name'=> $account['domain'],
|
'server_name'=> $account['domain'],
|
||||||
'bdd' => $account['bdd'],
|
'bdd' => $account['bdd'],
|
||||||
|
'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';
|
||||||
|
|
114
lib/bdd.php
114
lib/bdd.php
|
@ -43,17 +43,17 @@ class bdd {
|
||||||
private $db; /* resource of a created database */
|
private $db; /* resource of a created database */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @desc Open a sqlite database. Create it if it doesn't exist.
|
* @desc Open a sqlite database in rw mode. Create it if it doesn't exist.
|
||||||
* @param string $db_name Name of the sqlite database
|
* @param string $db_name Name of the sqlite database
|
||||||
*/
|
*/
|
||||||
public function open($db_name)
|
public function open($db_name)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$this->db = new SQLiteDatabase($db_name, 0666, $error);
|
$this->db = new SQLite3($db_name);
|
||||||
}
|
}
|
||||||
catch(Exception $e)
|
catch(Exception $e)
|
||||||
{
|
{
|
||||||
die ($error);
|
die ($e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,38 +83,38 @@ class bdd {
|
||||||
|
|
||||||
/* Table Accounts */
|
/* Table Accounts */
|
||||||
$query = 'CREATE Table Accounts ' .
|
$query = 'CREATE Table Accounts ' .
|
||||||
'(id INTEGER PRIMARY KEY , name TEXT, domain TEXT, bdd TEXT, replication TEXT, id_master INTEGER, id_slave INTEGER)';
|
'(id INTEGER PRIMARY KEY , name TEXT, domain TEXT, bdd TEXT, replication TEXT, id_master INTEGER, id_slave INTEGER, mail TEXT)';
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
{
|
{
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Table Servers */
|
/* Table Servers */
|
||||||
$query = 'CREATE Table Servers ' .
|
$query = 'CREATE Table Servers ' .
|
||||||
'(id INTEGER PRIMARY KEY , name TEXT, ip TEXT)';
|
'(id INTEGER PRIMARY KEY , name TEXT, ip TEXT)';
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
{
|
{
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Table ServersAlias */
|
/* Table ServersAlias */
|
||||||
$query = 'CREATE Table Serveralias ' .
|
$query = 'CREATE Table Serveralias ' .
|
||||||
'(id INTEGER PRIMARY KEY , domain TEXT, alias TEXT)';
|
'(id INTEGER PRIMARY KEY , domain TEXT, alias TEXT)';
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
{
|
{
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Table Roles */
|
/* Table Roles */
|
||||||
$query = 'CREATE Table Roles ' .
|
$query = 'CREATE Table Roles ' .
|
||||||
'(id INTEGER PRIMARY KEY , name TEXT, id_account INTEGER, id_server INTEGER)';
|
'(id INTEGER PRIMARY KEY , name TEXT, id_account INTEGER, id_server INTEGER)';
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
{
|
{
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,11 +124,12 @@ class bdd {
|
||||||
|
|
||||||
$query = "SELECT Servers.name FROM Servers, Roles where Roles.id = '$roleid' and Roles.id_server = Servers.id";
|
$query = "SELECT Servers.name FROM Servers, Roles where Roles.id = '$roleid' and Roles.id_server = Servers.id";
|
||||||
|
|
||||||
if ($result = $database->query($query, SQLITE_ASSOC, $error))
|
$result = $database->query($query);
|
||||||
|
if ($result != FALSE)
|
||||||
{
|
{
|
||||||
$row = $result->fetch();
|
$row = $result->fetchArray();
|
||||||
if (isset($row))
|
if (isset($row))
|
||||||
return $row['Servers.name'];
|
return $row['name'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -146,9 +147,10 @@ class bdd {
|
||||||
|
|
||||||
$query = "SELECT id FROM Accounts where name = '$account_name'";
|
$query = "SELECT id FROM Accounts where name = '$account_name'";
|
||||||
|
|
||||||
if ($result = $database->query($query, SQLITE_ASSOC, $error))
|
$result = $database->query($query);
|
||||||
|
if ($result != FALSE)
|
||||||
{
|
{
|
||||||
$row = $result->fetch();
|
$row = $result->fetchArray();
|
||||||
if (isset($row))
|
if (isset($row))
|
||||||
return $row['id'];
|
return $row['id'];
|
||||||
}
|
}
|
||||||
|
@ -167,9 +169,10 @@ class bdd {
|
||||||
|
|
||||||
$query = "SELECT * FROM Accounts where name = '$account_name'";
|
$query = "SELECT * FROM Accounts where name = '$account_name'";
|
||||||
|
|
||||||
if ($result = $database->query($query, SQLITE_ASSOC, $error))
|
$result = $database->query($query);
|
||||||
|
if ($result != FALSE)
|
||||||
{
|
{
|
||||||
$row = $result->fetch();
|
$row = $result->fetchArray();
|
||||||
if (isset($row))
|
if (isset($row))
|
||||||
return $row;
|
return $row;
|
||||||
else
|
else
|
||||||
|
@ -197,6 +200,7 @@ class bdd {
|
||||||
* 'domain' => "$domain",
|
* 'domain' => "$domain",
|
||||||
* 'bdd' => "bdd",
|
* 'bdd' => "bdd",
|
||||||
* 'replication' => "replication"
|
* 'replication' => "replication"
|
||||||
|
* 'mail' => "gmail|evolix"
|
||||||
* }
|
* }
|
||||||
* @return 1 on success,
|
* @return 1 on success,
|
||||||
* 0 else
|
* 0 else
|
||||||
|
@ -209,21 +213,23 @@ class bdd {
|
||||||
$domain = $account["domain"];
|
$domain = $account["domain"];
|
||||||
$bdd = $account["bdd"];
|
$bdd = $account["bdd"];
|
||||||
$replication = $account["replication"];
|
$replication = $account["replication"];
|
||||||
|
$mail = $account["mail"];
|
||||||
|
|
||||||
/* check if account exists */
|
/* check if account exists */
|
||||||
if ($this->is_account($name))
|
if ($this->is_account($name))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
$query = "INSERT INTO Accounts (name, domain, bdd, replication)
|
$query = "INSERT INTO Accounts (name, domain, bdd, replication, mail)
|
||||||
VALUES (
|
VALUES (
|
||||||
'$name',
|
'$name',
|
||||||
'$domain',
|
'$domain',
|
||||||
'$bdd',
|
'$bdd',
|
||||||
'$replication');";
|
'$replication',
|
||||||
|
'$mail');";
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
{
|
{
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -250,9 +256,9 @@ class bdd {
|
||||||
'$domain',
|
'$domain',
|
||||||
'$alias');";
|
'$alias');";
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
{
|
{
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -276,8 +282,8 @@ class bdd {
|
||||||
|
|
||||||
$query = "DELETE FROM Serveralias WHERE domain='$domain' AND alias='$alias';";
|
$query = "DELETE FROM Serveralias WHERE domain='$domain' AND alias='$alias';";
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -294,9 +300,10 @@ class bdd {
|
||||||
|
|
||||||
$query = "SELECT id FROM Servers where name = '$server_name'";
|
$query = "SELECT id FROM Servers where name = '$server_name'";
|
||||||
|
|
||||||
if ($result = $database->query($query, SQLITE_ASSOC, $error))
|
$result = $database->query($query);
|
||||||
|
if ($result != FALSE)
|
||||||
{
|
{
|
||||||
$row = $result->fetch();
|
$row = $result->fetchArray();
|
||||||
if (isset($row))
|
if (isset($row))
|
||||||
return $row['id'];
|
return $row['id'];
|
||||||
}
|
}
|
||||||
|
@ -339,8 +346,8 @@ class bdd {
|
||||||
'$name'
|
'$name'
|
||||||
);";
|
);";
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -373,8 +380,8 @@ class bdd {
|
||||||
'$id_account',
|
'$id_account',
|
||||||
'$id_server')";
|
'$id_server')";
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
|
|
||||||
$id = $database->lastInsertRowid();
|
$id = $database->lastInsertRowid();
|
||||||
|
|
||||||
|
@ -382,8 +389,8 @@ class bdd {
|
||||||
if (($role === 'master') || ($role === 'slave'))
|
if (($role === 'master') || ($role === 'slave'))
|
||||||
$query = "UPDATE Accounts SET id_$role = '$id' WHERE id = '$id_account'";
|
$query = "UPDATE Accounts SET id_$role = '$id' WHERE id = '$id_account'";
|
||||||
|
|
||||||
if (!$database->queryExec($query, $error))
|
if (!$database->exec($query))
|
||||||
die($error);
|
die($database->lastErrorMsg());
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -423,12 +430,13 @@ class bdd {
|
||||||
$database = $this->db;
|
$database = $this->db;
|
||||||
|
|
||||||
$query = "SELECT * FROM Accounts, Roles, Servers WHERE Accounts.id = Roles.id_account AND Roles.id_server = Servers.id";
|
$query = "SELECT * FROM Accounts, Roles, Servers WHERE Accounts.id = Roles.id_account AND Roles.id_server = Servers.id";
|
||||||
if($result = $database->query($query, SQLITE_ASSOC, $error))
|
$result = $database->query($query);
|
||||||
|
if($result != FALSE)
|
||||||
{
|
{
|
||||||
$domains = array();
|
$domains = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while($row = $result->fetch())
|
while($row = $result->fetchArray())
|
||||||
{
|
{
|
||||||
$domains[$i] = $row;
|
$domains[$i] = $row;
|
||||||
++$i;
|
++$i;
|
||||||
|
@ -446,12 +454,13 @@ class bdd {
|
||||||
|
|
||||||
$query = "SELECT * FROM Accounts";
|
$query = "SELECT * FROM Accounts";
|
||||||
|
|
||||||
if($result = $database->query($query, SQLITE_ASSOC, $error))
|
$result = $database->query($query);
|
||||||
|
if ($result != FALSE)
|
||||||
{
|
{
|
||||||
$accounts = array();
|
$accounts = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while($row = $result->fetch())
|
while($row = $result->fetchArray())
|
||||||
{
|
{
|
||||||
$accounts[$i] = $row;
|
$accounts[$i] = $row;
|
||||||
++$i;
|
++$i;
|
||||||
|
@ -472,12 +481,13 @@ class bdd {
|
||||||
|
|
||||||
$query = "SELECT * FROM Serveralias WHERE domain = '$domain'";
|
$query = "SELECT * FROM Serveralias WHERE domain = '$domain'";
|
||||||
|
|
||||||
if ($result = $database->query($query, SQLITE_ASSOC, $error))
|
$result = $database->query($query);
|
||||||
|
if ($result != FALSE)
|
||||||
{
|
{
|
||||||
$serveralias = array();
|
$serveralias = array();
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
while($row = $result->fetch())
|
while($row = $result->fetchArray())
|
||||||
{
|
{
|
||||||
$serveralias[$i] = $row;
|
$serveralias[$i] = $row;
|
||||||
++$i;
|
++$i;
|
||||||
|
@ -488,4 +498,26 @@ class bdd {
|
||||||
|
|
||||||
return $serveralias;
|
return $serveralias;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function is_serveralias($domain, $alias)
|
||||||
|
{
|
||||||
|
$database = $this->db;
|
||||||
|
|
||||||
|
if ($domain == NULL)
|
||||||
|
return 0;
|
||||||
|
if ($alias == NULL)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
$query = "SELECT id FROM Serveralias WHERE domain = '$domain' and alias = '$alias'";
|
||||||
|
|
||||||
|
$result = $database->query($query);
|
||||||
|
if ($result != FALSE)
|
||||||
|
{
|
||||||
|
$row = $result->fetchArray();
|
||||||
|
return !!($row['id']);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
53
lib/domain.php
Normal file
53
lib/domain.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
function domain_add($name, $IP, $with_mxs, $gmail=false) {
|
||||||
|
|
||||||
|
$exec_cmd = 'bind-add-ng.sh';
|
||||||
|
|
||||||
|
if ( $with_mxs == true ) {
|
||||||
|
/* Quai13 specific: use Gmail MXs if wanted */
|
||||||
|
if ( $gmail ) {
|
||||||
|
$exec_cmd .= ' -m ASPMX.L.GOOGLE.com.,10';
|
||||||
|
$exec_cmd .= ' -m ALT1.ASPMX.L.GOOGLE.com.,20';
|
||||||
|
$exec_cmd .= ' -m ALT2.ASPMX.L.GOOGLE.com.,20';
|
||||||
|
$exec_cmd .= ' -m ASPMX2.GOOGLEMAIL.com.,30';
|
||||||
|
$exec_cmd .= ' -m ASPMX3.GOOGLEMAIL.com.,30';
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$exec_cmd .= ' -m mail,10';
|
||||||
|
$exec_cmd .= ' -m backup.quai13.net.,20';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$exec_cmd .= " -a $IP $name";
|
||||||
|
|
||||||
|
sudoexec($exec_cmd, $exec_output, $exec_return);
|
||||||
|
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;
|
||||||
|
}
|
217
lib/letsencrypt.php
Normal file
217
lib/letsencrypt.php
Normal file
|
@ -0,0 +1,217 @@
|
||||||
|
<?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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
Include "/etc/awstats/awstats.conf.local"
|
Include "/etc/awstats/awstats.conf"
|
||||||
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"
|
||||||
|
|
213
scripts/bind-add-ng.sh
Executable file
213
scripts/bind-add-ng.sh
Executable file
|
@ -0,0 +1,213 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
BINDROOT="/etc/bind"
|
||||||
|
DBTEMPLATE="$BINDROOT/db.example.com"
|
||||||
|
SLAVE="ns4.evolix.net"
|
||||||
|
LOGFILE="/var/log/bind-add.log"
|
||||||
|
ADD_DOMAIN_SLAVE="/usr/share/scripts/add_domain_slave_ns4.sh"
|
||||||
|
ADD_RELAY_DOMAIN="/usr/share/scripts/add_relay_domains.sh"
|
||||||
|
|
||||||
|
# Redirect stderr to $LOGFILE since Evoadmin don't catch stderr correctly.
|
||||||
|
#exec 2>>$LOGFILE
|
||||||
|
# Duplicate stderr on $LOGFILE (bashism)
|
||||||
|
exec 2> >(tee -a $LOGFILE >&2)
|
||||||
|
|
||||||
|
# Create zone file for a new domain.
|
||||||
|
create_domain () {
|
||||||
|
domain="$1"
|
||||||
|
ip="$2"
|
||||||
|
|
||||||
|
zonefile="$BINDROOT/db.$domain"
|
||||||
|
|
||||||
|
# Create new zone file
|
||||||
|
cp -p $DBTEMPLATE $zonefile
|
||||||
|
sed -i "s/_IP_/$ip/" $zonefile
|
||||||
|
|
||||||
|
# Add domain to bind conf
|
||||||
|
sed "s/__DATE__/`date "+%d.%m.%Y"`/; s/example.com/$domain/" \
|
||||||
|
$BINDROOT/named.conf.single >> $BINDROOT/named.conf.evolix
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add a MX record to an existing domain.
|
||||||
|
add_mx () {
|
||||||
|
domain="$1"
|
||||||
|
mx="$2"
|
||||||
|
mx_priority="$3"
|
||||||
|
mx_subdomain="$4"
|
||||||
|
|
||||||
|
zonefile="$BINDROOT/db.$domain"
|
||||||
|
|
||||||
|
# Quai13 specific. See #8053.
|
||||||
|
if [ "$mx_subdomain" != "@" ]; then
|
||||||
|
log INFO "Not adding MX record for subdomain $mx_subdomain."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! grep -q -P "^$mx_subdomain[ \t]+IN[ \t]+MX[ \t]+[[:digit:]]+[ \t]+$mx$" $zonefile; then
|
||||||
|
echo "$mx_subdomain IN MX $mx_priority $mx" >>$zonefile
|
||||||
|
else
|
||||||
|
log ERR "MX Record $mx already exists."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Add a subdomain (CNAME) to an existing domain.
|
||||||
|
add_subdomain () {
|
||||||
|
domain="$1"
|
||||||
|
subdomain="$2"
|
||||||
|
|
||||||
|
zonefile="$BINDROOT/db.$domain"
|
||||||
|
|
||||||
|
if ! grep -q -P "^$subdomain[ \t]+IN[ \t]+(CNAME|A)[ \t]+" $zonefile; then
|
||||||
|
echo "$subdomain IN CNAME @" >>$zonefile
|
||||||
|
else
|
||||||
|
log ERR "CNAME or A record for $subdomain already exists."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Incremente serial number for a domain, check zone, and reload rndc daemon.
|
||||||
|
inc_and_reload () {
|
||||||
|
domain="$1"
|
||||||
|
|
||||||
|
zonefile="$BINDROOT/db.$domain"
|
||||||
|
|
||||||
|
# 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/")
|
||||||
|
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/" \
|
||||||
|
$zonefile
|
||||||
|
if stderr=$(named-checkzone $domain $zonefile 2>&1); then
|
||||||
|
rndc reload
|
||||||
|
else
|
||||||
|
log ERR "named-checkzone returns non zero exit code: $stderr"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# Send mail to staff to create domain on the slave server.
|
||||||
|
send_mail () {
|
||||||
|
#addr_master=$(ifconfig eth0 |perl -ne 'print "$1" if /addr:([\d\.]+)/')
|
||||||
|
echo "IP du serveur maitre : 46.105.42.13" |
|
||||||
|
mail -s "[TAF] Ajouter le domaine $domain sur $SLAVE" tech@evolix.fr
|
||||||
|
}
|
||||||
|
|
||||||
|
usage () {
|
||||||
|
cat >&2 <<EOT
|
||||||
|
Usage: $0 -a <A record> [-m <MX record>,<priority>] [-s subdomain] domain
|
||||||
|
E.g.: $0 -a 192.0.2.12 -m mail,10 -s foo example.net
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
- -m and -s options can be specified multiple times to add multiple MX
|
||||||
|
records and/or subdomains
|
||||||
|
- you can also create a subdomain "foo" with this syntax (even if example.net
|
||||||
|
is not yet created):
|
||||||
|
$0 foo.example.net
|
||||||
|
EOT
|
||||||
|
}
|
||||||
|
|
||||||
|
log () {
|
||||||
|
level="$1"
|
||||||
|
message="$2"
|
||||||
|
|
||||||
|
if [ "$level" = "ERR" ]; then
|
||||||
|
echo -n "$(date +"%b %d %T") " >>$LOGFILE
|
||||||
|
echo "ERROR: $message" |tee -a $LOGFILE >&2
|
||||||
|
elif [ "$level" = "INFO" ]; then
|
||||||
|
echo -n "$(date +"%b %d %T") " >>$LOGFILE
|
||||||
|
echo "INFO: $message" |tee -a $LOGFILE
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
log INFO "$0 $*"
|
||||||
|
|
||||||
|
# Options parsing.
|
||||||
|
|
||||||
|
while getopts 'a:s:m:' opt; do
|
||||||
|
case $opt in
|
||||||
|
a)
|
||||||
|
ip=$OPTARG
|
||||||
|
;;
|
||||||
|
s)
|
||||||
|
subdomains="$subdomains $OPTARG"
|
||||||
|
;;
|
||||||
|
m)
|
||||||
|
mxs="$mxs $OPTARG"
|
||||||
|
;;
|
||||||
|
\?)
|
||||||
|
log ERR "Invalid option -$OPTARG."
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND-1))
|
||||||
|
|
||||||
|
if [ $# -eq 1 ]; then
|
||||||
|
fqdn=$(echo $1 |tr '[:upper:]' '[:lower:]')
|
||||||
|
else
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# If the domain contains a subdomain, extracts it.
|
||||||
|
if [ $(echo "$fqdn" |grep -oF '.' |wc -l) -gt 1 ]; then
|
||||||
|
domain=$(echo $fqdn |grep -o '[^\.]\+\.[^\.]\+$')
|
||||||
|
if [ ${fqdn%.$domain} != "www" ]; then # www is already present in the zone template, so skip it.
|
||||||
|
subdomains="$subdomains ${fqdn%.$domain}"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
domain="$fqdn"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f $BINDROOT/db.$domain ]; then
|
||||||
|
log INFO "Creating domain $domain."
|
||||||
|
if [ -n "$ip" ]; then
|
||||||
|
create_domain $domain $ip
|
||||||
|
#send_mail $domain
|
||||||
|
$ADD_DOMAIN_SLAVE $domain
|
||||||
|
$ADD_RELAY_DOMAIN $domain
|
||||||
|
else
|
||||||
|
log ERR "Domain $domain does not exist and -a option is not set."
|
||||||
|
log "Could not create domain."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log INFO "domain $domain created successfully."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$mxs" ]; then
|
||||||
|
for mx in $mxs; do
|
||||||
|
log INFO "Adding MX record $mx to domain $domain."
|
||||||
|
mx_domain=$(echo $mx |cut -d ',' -f '1')
|
||||||
|
mx_priority=$(echo $mx |cut -d ',' -f '2')
|
||||||
|
mx_subdomain="${fqdn%.$domain}"
|
||||||
|
if [ "$mx_subdomain" = "$domain" ] || [ "$mx_subdomain" = "www" ]; then
|
||||||
|
mx_subdomain="@"
|
||||||
|
fi
|
||||||
|
if ! add_mx $domain $mx_domain $mx_priority "$mx_subdomain"; then
|
||||||
|
log ERR "Error: adding MX record failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log INFO "MX record $mx added successfully to domain $domain."
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$subdomains" ]; then
|
||||||
|
for subdomain in $subdomains; do
|
||||||
|
log INFO "Adding CNAME record $subdomain to domain $domain."
|
||||||
|
if ! add_subdomain $domain $subdomain; then
|
||||||
|
log ERR "Error: adding CNAME record failed."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log INFO "CNAME record $subdomain added successfully to domain $domain."
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
log INFO "Reloading rndc."
|
||||||
|
if ! inc_and_reload $domain; then
|
||||||
|
log ERR "Error: zone not loaded due to errors."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
log INFO "rndc reloaded successfully."
|
101
scripts/dbadmin.sh
Executable file
101
scripts/dbadmin.sh
Executable file
|
@ -0,0 +1,101 @@
|
||||||
|
#!/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
|
18
scripts/fpm.conf.tpl
Normal file
18
scripts/fpm.conf.tpl
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
[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
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
############################################################
|
############################################################
|
||||||
# #
|
# #
|
||||||
|
@ -13,6 +13,11 @@
|
||||||
|
|
||||||
# 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"
|
||||||
|
|
||||||
|
@ -48,48 +53,38 @@ 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
|
||||||
|
|
||||||
account_list=''
|
# Remove # and empty lines
|
||||||
oldIFS=IFS
|
ftp_users=$(grep -v -E '^[[:blank:]]*(#.*)*$' "$VPASSWD_PATH")
|
||||||
IFS=$'\n'
|
|
||||||
|
|
||||||
for line in `cat $VPASSWD_PATH`
|
for line in $ftp_users; do
|
||||||
do
|
line_uid="$(echo "$line" | cut -d":" -f3)"
|
||||||
line_uid=`echo $line | cut -d":" -f3`
|
|
||||||
|
|
||||||
if [ ! "$uid" ] || [ "$line_uid" == "$uid" ]; then
|
if [[ ! "$uid" ]] || [[ "$line_uid" == "$uid" ]]; then
|
||||||
username=`get_user_login_by_UID $line_uid`
|
username=$(get_user_login_by_UID "$line_uid")
|
||||||
account=`echo $line | cut -d":" -f1`
|
account=$(echo "$line" | cut -d":" -f1)
|
||||||
path=`echo $line | cut -d":" -f6`
|
path=$(echo "$line" | cut -d":" -f6)
|
||||||
if [ -r $path/.size ]; then
|
size="inconnue"
|
||||||
size=`cat $path/.size`
|
# Check output of daily "du" cron job
|
||||||
else
|
# (set by ansible-roles/packweb-apache/tasks/main.yml)
|
||||||
size=0
|
if [ -r "$path/.size" ]; then
|
||||||
|
size=$(cat "$path/.size")
|
||||||
fi
|
fi
|
||||||
#modif=`cat $path/.lastmodified`
|
#modif="$(cat $path/.lastmodified)"
|
||||||
# Passage en minuscule ?
|
echo "$username:$account:$path:$size${modif:+:$modif}"
|
||||||
#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
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
echo "$account_list"
|
|
||||||
|
|
||||||
IFS=$oldIFS
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_account() {
|
add_account() {
|
||||||
|
@ -99,18 +94,17 @@ 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époertoire de travail du compte FTP n'existe pas, on le crée
|
# Si le répertoire 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 `echo $passwd | ftpasswd --passwd --file=$VPASSWD_PATH --name=$account_name --uid=$user_id --gid=$user_gid --home=$path --shell=/bin/false --stdin`
|
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)"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,7 +112,7 @@ edit_password() {
|
||||||
account_name=$1
|
account_name=$1
|
||||||
passwd=$2
|
passwd=$2
|
||||||
|
|
||||||
echo `echo $passwd | ftpasswd --passwd --file=$VPASSWD_PATH --name=$account_name --uid=9999 --gid=9999 --home=/dev/null --shell=/dev/null --change-password --stdin`
|
echo "$passwd" | ftpasswd --passwd --file="$VPASSWD_PATH" --name="$account_name" --uid=9999 --gid=9999 --home=/dev/null --shell=/dev/null --change-password --stdin
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -127,12 +121,11 @@ delete_account() {
|
||||||
|
|
||||||
account_name=$1
|
account_name=$1
|
||||||
|
|
||||||
echo `ftpasswd --passwd --file=$VPASSWD_PATH --name=$account_name --uid=9999 --gid=9999 --home=/dev/null --shell=/dev/null --delete-user`
|
ftpasswd --passwd --file=$VPASSWD_PATH --name="$account_name" --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
|
||||||
|
@ -149,26 +142,67 @@ while getopts a:u:n:f:p: opt; do
|
||||||
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)
|
||||||
account_list=`list_accounts_by_UID $in_userid`
|
echo -e "$(list_accounts_by_UID "${in_userid-}")"
|
||||||
echo -e -n $account_list
|
|
||||||
exit 1
|
exit 1
|
||||||
;;
|
;;
|
||||||
a)
|
a)
|
||||||
echo -e -n `add_account $in_userid $in_accountname $in_workpath $in_password`
|
if [[ -z "${in_userid-}" ]]; then
|
||||||
|
echo "User ID not specified"
|
||||||
|
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
|
exit 1
|
||||||
;;
|
;;
|
||||||
m)
|
m)
|
||||||
echo -e -n `edit_password $in_accountname $in_password`
|
if [[ -z "${in_accountname-}" ]]; then
|
||||||
|
echo "Account name not specified"
|
||||||
|
elif [[ -z "${in_password-}" ]]; then
|
||||||
|
echo "A password was not specified"
|
||||||
|
else
|
||||||
|
echo -e -n \
|
||||||
|
"$(edit_password \
|
||||||
|
"$in_accountname" \
|
||||||
|
"$in_password")"
|
||||||
|
fi
|
||||||
exit 1;
|
exit 1;
|
||||||
;;
|
;;
|
||||||
d)
|
d)
|
||||||
echo -e -n `delete_account $in_accountname`
|
if [[ -z "${in_accountname-}" ]]; then
|
||||||
|
echo "Account name not specified"
|
||||||
|
else
|
||||||
|
echo -e -n \
|
||||||
|
"$(delete_account "$in_accountname")"
|
||||||
|
fi
|
||||||
exit 1;
|
exit 1;
|
||||||
;;
|
;;
|
||||||
|
*)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
48
scripts/my-edit.sh
Normal file
48
scripts/my-edit.sh
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/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
|
|
@ -1,23 +1,13 @@
|
||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
for dir in `cat /etc/proftpd/vpasswd | cut -d : -f 6`; do
|
set -o errexit
|
||||||
#for dir in /home/dalleFTP/reynaud_mila; do
|
set -o nounset
|
||||||
if [ -d $dir ]; then
|
#set -x
|
||||||
du -s $dir | cut -f 1 >$dir/.size
|
|
||||||
chmod 644 $dir/.size
|
|
||||||
|
|
||||||
#mtime=0
|
cut -d : -f 6 /etc/proftpd/vpasswd | while read -r dir; do
|
||||||
#export IFS=$'\n'
|
if [ -d "$dir" ]; then
|
||||||
#for file in `find $dir -type f -not -name .size -not -name .last-modified`; do
|
du -s "$dir" | cut -f 1 > "$dir"/.size
|
||||||
# timestamp=`stat -c %Y $file`
|
chmod 644 "$dir"/.size
|
||||||
# if [ $timestamp -gt $mtime ]; then
|
|
||||||
# mtime=$timestamp
|
|
||||||
# fi
|
|
||||||
#done
|
|
||||||
#unset IFS
|
|
||||||
|
|
||||||
#echo $mtime >$dir/.lastmodified
|
|
||||||
#chmod 644 $dir/.lastmodified
|
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
<VirtualHost *:80>
|
<VirtualHost *:80 *:443>
|
||||||
|
|
||||||
# FQDN principal
|
# FQDN principal
|
||||||
ServerName SERVERNAME
|
ServerName SERVERNAME
|
||||||
|
@ -7,28 +7,34 @@
|
||||||
# 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
|
||||||
Options SymLinksIfOwnerMatch
|
Options +SymLinksIfOwnerMatch
|
||||||
AllowOverride AuthConfig Limit FileInfo
|
AllowOverride AuthConfig Limit FileInfo
|
||||||
|
Require all granted
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
# CGI
|
# CGI
|
||||||
ScriptAlias /cgi-RANDOM /usr/lib/cgi-bin/
|
ScriptAlias /cgi-RANDOM /usr/lib/cgi-bin/
|
||||||
<Directory /usr/lib/cgi-bin/>
|
<Directory /usr/lib/cgi-bin/>
|
||||||
Options ExecCGI -MultiViews
|
Options +ExecCGI -MultiViews
|
||||||
AllowOverride None
|
AllowOverride None
|
||||||
|
|
||||||
AuthName "Restricted"
|
AuthName "Restricted"
|
||||||
AuthUserFile HOME_DIR/XXX/.htpasswd
|
AuthUserFile HOME_DIR/XXX/.htpasswd
|
||||||
AuthGroupFile /dev/null
|
|
||||||
AuthType Basic
|
AuthType Basic
|
||||||
require valid-user
|
require valid-user
|
||||||
|
|
||||||
Order Deny,Allow
|
Order Deny,Allow
|
||||||
Deny from all
|
Deny from all
|
||||||
#Allow from YYY.YYY.YYY.YYY
|
|
||||||
|
#Include /etc/apache2/ipaddr_whitelist.conf
|
||||||
|
|
||||||
Satisfy any
|
Satisfy any
|
||||||
</Directory>
|
</Directory>
|
||||||
|
@ -37,7 +43,7 @@
|
||||||
AssignUserID www-XXX XXX
|
AssignUserID www-XXX XXX
|
||||||
|
|
||||||
# LOG
|
# LOG
|
||||||
CustomLog /var/log/apache2/access.log combined
|
CustomLog /var/log/apache2/access.log vhost_combined
|
||||||
CustomLog HOME_DIR/XXX/log/access.log combined
|
CustomLog HOME_DIR/XXX/log/access.log combined
|
||||||
ErrorLog HOME_DIR/XXX/log/error.log
|
ErrorLog HOME_DIR/XXX/log/error.log
|
||||||
|
|
||||||
|
@ -47,8 +53,6 @@
|
||||||
# REWRITE
|
# REWRITE
|
||||||
UseCanonicalName On
|
UseCanonicalName On
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
RewriteLog "/var/log/apache2/rewrite.log"
|
|
||||||
RewriteLogLevel 0
|
|
||||||
RewriteCond %{HTTP_HOST} !^SERVERNAME$
|
RewriteCond %{HTTP_HOST} !^SERVERNAME$
|
||||||
RewriteRule ^/(.*) http://%{SERVER_NAME}/$1 [L,R]
|
RewriteRule ^/(.*) http://%{SERVER_NAME}/$1 [L,R]
|
||||||
|
|
||||||
|
@ -62,11 +66,6 @@
|
||||||
#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>
|
|
||||||
|
|
||||||
# vim: set filetype=apache expandtab shiftwidth=4 softtabstop=4 tabstop=4 :
|
|
||||||
|
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
AllowOverride None
|
AllowOverride None
|
||||||
|
|
||||||
Deny from all
|
Deny from all
|
||||||
|
|
||||||
#Allow from XXX.XXX.XXX.XXX
|
#Allow from XXX.XXX.XXX.XXX
|
||||||
</Directory>
|
</Directory>
|
||||||
|
|
||||||
|
|
41
scripts/vhost-nginx.tpl
Normal file
41
scripts/vhost-nginx.tpl
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
|
@ -16,8 +16,8 @@
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
HOME="/root"
|
HOME="/root"
|
||||||
CONTACT_MAIL=""
|
CONTACT_MAIL="jdoe@example.org"
|
||||||
WWWBOUNCE_MAIL=""
|
WWWBOUNCE_MAIL="jdoe@example.org"
|
||||||
LOCAL_SCRIPT="/usr/share/scripts/web-add.local.sh"
|
LOCAL_SCRIPT="/usr/share/scripts/web-add.local.sh"
|
||||||
PRE_LOCAL_SCRIPT="/usr/share/scripts/web-add.pre-local.sh"
|
PRE_LOCAL_SCRIPT="/usr/share/scripts/web-add.pre-local.sh"
|
||||||
TPL_VHOST="/usr/share/scripts/vhost"
|
TPL_VHOST="/usr/share/scripts/vhost"
|
||||||
|
@ -36,7 +36,7 @@ LAST_UID="cut -d: -f3 /etc/passwd | grep -v $NOBODY_UID | sort -n | tail -1"
|
||||||
VMAIL_USER="vmail"
|
VMAIL_USER="vmail"
|
||||||
|
|
||||||
# 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/evolix/web-add.conf"
|
config_file="/etc/evolinux/web-add.conf"
|
||||||
[ -r $config_file ] && . $config_file
|
[ -r $config_file ] && . $config_file
|
||||||
|
|
||||||
usage() {
|
usage() {
|
||||||
|
@ -265,15 +265,20 @@ create_www_accounts() {
|
||||||
|
|
||||||
if [ "$in_replmode" != "realtime" ]; then
|
if [ "$in_replmode" != "realtime" ]; then
|
||||||
|
|
||||||
echo "SLAVE: $CMD_SLAVE $WEBADD add -p '$in_passwd' $opts_mysql -l $in_mail -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain"
|
echo "SLAVE: $CMD_SLAVE $WEBADD add -p '$in_passwd' $opts_mysql -l null@example.org -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain"
|
||||||
$CMD_SLAVE $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 slave sur $in_slave: $?" && exit 1)
|
$CMD_SLAVE $WEBADD add -p \'$in_passwd\' $opts_mysql -l null@example.org -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain || (in_error "creation du compte slave sur $in_slave: $?" && exit 1)
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
echo "SLAVE: $CMD_SLAVE $WEBADD add -p '$in_passwd' -l $in_mail -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain"
|
echo "SLAVE: $CMD_SLAVE $WEBADD add -p '$in_passwd' -l null@example.org -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain"
|
||||||
$CMD_SLAVE $WEBADD add -p \'$in_passwd\' -l $in_mail -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain || (in_error "creation du compte slave sur $in_slave: $?" && exit 1)
|
$CMD_SLAVE $WEBADD add -p \'$in_passwd\' -l null@example.org -y -u $uid -g $uid -U $(($uid + 1)) $in_login $in_wwwdomain || (in_error "creation du compte slave sur $in_slave: $?" && exit 1)
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# On ne veut pas que le site soit actif sur le serveur slave
|
||||||
|
$CMD_SLAVE a2dissite $in_login
|
||||||
|
$CMD_SLAVE /etc/init.d/apache2 reload
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Les operation suivantes sont faites uniquement si une replication doit
|
# Les operation suivantes sont faites uniquement si une replication doit
|
||||||
|
@ -375,12 +380,12 @@ ENDSSH
|
||||||
cron_line="*/$in_replinterval * * * * /opt/evocluster/sync-master-to-slave.sh"
|
cron_line="*/$in_replinterval * * * * /opt/evocluster/sync-master-to-slave.sh"
|
||||||
cron_line2="*/$in_replinterval * * * * /opt/evocluster/get-domains.sh $in_login |while read domain; do /opt/evocluster/sync-master-to-slave_mail.sh \$domain $in_login; done"
|
cron_line2="*/$in_replinterval * * * * /opt/evocluster/get-domains.sh $in_login |while read domain; do /opt/evocluster/sync-master-to-slave_mail.sh \$domain $in_login; done"
|
||||||
elif [ $in_replunit = "hour" ]; then
|
elif [ $in_replunit = "hour" ]; then
|
||||||
minute=$(($RANDOM % 60))
|
minute=$(($RANDOM % 54))
|
||||||
offset=5
|
offset=5
|
||||||
cron_line="$minute */$in_replinterval * * * /opt/evocluster/sync-master-to-slave.sh"
|
cron_line="$minute */$in_replinterval * * * /opt/evocluster/sync-master-to-slave.sh"
|
||||||
cron_line2="$(($minute+$offset)) */$in_replinterval * * * /opt/evocluster/get-domains.sh $in_login |while read domain; do /opt/evocluster/sync-master-to-slave_mail.sh \$domain $in_login; done"
|
cron_line2="$(($minute+$offset)) */$in_replinterval * * * /opt/evocluster/get-domains.sh $in_login |while read domain; do /opt/evocluster/sync-master-to-slave_mail.sh \$domain $in_login; done"
|
||||||
fi
|
fi
|
||||||
$CMD_MASTER "(crontab -lu $in_login; echo \"$cron_line\") |crontab -u $in_login -"
|
$CMD_MASTER "(crontab -lu $in_login; echo -e \"$cron_line\") |crontab -u $in_login -"
|
||||||
$CMD_MASTER "(crontab -lu $VMAIL_USER; echo '$cron_line2') |crontab -u $VMAIL_USER -"
|
$CMD_MASTER "(crontab -lu $VMAIL_USER; echo '$cron_line2') |crontab -u $VMAIL_USER -"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -420,13 +425,13 @@ op_del() {
|
||||||
|
|
||||||
# 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
|
||||||
error "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
|
||||||
error "Account $login doesn't exist on $slave";
|
echo "Account $login doesn't exist on $slave";
|
||||||
exit 1;
|
exit 1;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
649
scripts/web-add-nginx.sh
Executable file
649
scripts/web-add-nginx.sh
Executable file
|
@ -0,0 +1,649 @@
|
||||||
|
#!/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 $*
|
||||||
|
|
1095
scripts/web-add.sh
1095
scripts/web-add.sh
|
@ -1,10 +1,9 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
#
|
#
|
||||||
# Gestion des comptes web et des hôtes virtuels Apache
|
# Gestion des comptes web et des hôtes virtuels pour Apache et Nginx
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 Evolix - Tous droits reserves
|
# Copyright (c) 2009-2017 Evolix - Tous droits reserves
|
||||||
# $Id$
|
|
||||||
#
|
#
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
@ -15,26 +14,53 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
VERSION="24.04"
|
||||||
HOME="/root"
|
HOME="/root"
|
||||||
CONTACT_MAIL=""
|
CONTACT_MAIL="jdoe@example.org"
|
||||||
WWWBOUNCE_MAIL=""
|
WWWBOUNCE_MAIL="jdoe@example.org"
|
||||||
LOCAL_SCRIPT="/usr/share/scripts/web-add.local.sh"
|
SCRIPTS_PATH="/usr/share/scripts/evoadmin"
|
||||||
PRE_LOCAL_SCRIPT="/usr/share/scripts/web-add.pre-local.sh"
|
LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.local.sh"
|
||||||
TPL_VHOST="/usr/share/scripts/vhost"
|
PRE_LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.pre-local.sh"
|
||||||
TPL_AWSTATS="/usr/share/scripts/awstats.XXX.conf"
|
TPL_AWSTATS="$SCRIPTS_PATH/awstats.XXX.conf"
|
||||||
TPL_MAIL="/usr/share/scripts/web-mail.tpl"
|
SSH_GROUP="evolinux-ssh"
|
||||||
VHOST_PATH="/etc/apache2/sites-enabled/"
|
HOST="$(hostname -f)"
|
||||||
|
|
||||||
|
# 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=""
|
||||||
|
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/evolix/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 ]
|
||||||
|
@ -69,18 +95,34 @@ add [ [OPTIONS] LOGIN WWWDOMAIN ]
|
||||||
-y
|
-y
|
||||||
Don't ask for confirmation
|
Don't ask for confirmation
|
||||||
|
|
||||||
Example : web-add.sh add -m testdb testlogin testdomain.com
|
-r
|
||||||
|
PHP version (without dot)
|
||||||
|
|
||||||
del LOGIN [DBNAME]
|
-q
|
||||||
|
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
|
||||||
|
@ -89,6 +131,53 @@ 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +194,7 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
gen_random_passwd() {
|
gen_random_passwd() {
|
||||||
apg -c /dev/urandom -n1 -E oOlL10\&\\\/\"\'
|
apg -c /dev/urandom -MNCL -n1 -m18 -E oOlL10
|
||||||
}
|
}
|
||||||
|
|
||||||
validate_login() {
|
validate_login() {
|
||||||
|
@ -113,12 +202,12 @@ validate_login() {
|
||||||
|
|
||||||
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
|
||||||
|
@ -128,7 +217,7 @@ 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
|
||||||
|
@ -136,7 +225,7 @@ validate_passwd() {
|
||||||
|
|
||||||
validate_dbname() {
|
validate_dbname() {
|
||||||
dbname=$1
|
dbname=$1
|
||||||
if mysql -ss -e "show databases" | grep "^$dbname$" >/dev/null; then
|
if mysql $MYSQL_OPTS -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
|
||||||
|
@ -148,6 +237,15 @@ validate_wwwdomain() {
|
||||||
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
|
||||||
|
*'/'*)
|
||||||
|
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
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -155,6 +253,26 @@ 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"
|
||||||
|
@ -173,6 +291,7 @@ create_www_account() {
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
if [ -f $PRE_LOCAL_SCRIPT ]; then
|
if [ -f $PRE_LOCAL_SCRIPT ]; then
|
||||||
|
# shellcheck source=/usr/share/scripts/evoadmin/web-add.pre-local.sh
|
||||||
source $PRE_LOCAL_SCRIPT
|
source $PRE_LOCAL_SCRIPT
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -191,91 +310,223 @@ create_www_account() {
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
############################################################################
|
# Create user and force UID / GID if specified
|
||||||
|
/usr/sbin/adduser \
|
||||||
|
--gecos "User $in_login" \
|
||||||
|
--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
|
||||||
|
|
||||||
# Force UID GID if specified
|
[ -z "$in_sshkey" ] \
|
||||||
|
&& echo "$in_login:$in_passwd" | chpasswd
|
||||||
|
|
||||||
[ -n "$in_uid" ] && OPT_UID="--uid" && OPT_UID_ARG="$in_uid"
|
[ -z "$in_sshkey" ] \
|
||||||
[ -n "$in_gid" ] && OPT_GID="--gid" && OPT_GID_ARG="$in_gid"
|
|| [ -n "$HOME_DIR_USER" ] \
|
||||||
[ -n "$in_wwwuid" ] && OPT_WWWUID="--uid" && OPT_WWWUID_ARG="$in_wwwuid"
|
&& 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
|
||||||
|
# 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
|
||||||
|
uid=$(id -u "$in_login")
|
||||||
|
gid=$(id -g "$in_login")
|
||||||
|
www_uid=$(id -u www-"$in_login")
|
||||||
|
|
||||||
/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
|
# Create users inside all containers
|
||||||
[ -z "$in_sshkey" ] && echo "$in_login:$in_passwd" | chpasswd --md5
|
for php_version in "${PHP_VERSIONS[@]}"; do
|
||||||
[ -z "$in_sshkey" ] || [ -n "$HOME_DIR_USER" ] && mkdir "$HOME_DIR_USER/.ssh" && echo "$in_sshkey" > "$HOME_DIR_USER/.ssh/authorized_keys" \
|
lxc-attach -n php"${php_version}" -- /usr/sbin/addgroup "$in_login" --gid "$gid" --force-badname >/dev/null
|
||||||
&& chmod -R u=rwX,g=,o= "$HOME_DIR_USER/.ssh/authorized_keys" && chown -R "$in_login":"$in_login" "$HOME_DIR_USER/.ssh"
|
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
|
||||||
|
lxc-attach -n php"${php_version}" -- [ -z "$in_sshkey" ] && echo "$in_login:$in_passwd" | chpasswd
|
||||||
/usr/sbin/adduser --disabled-password --home $HOME_DIR_USER/www \
|
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
|
||||||
--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
|
done
|
||||||
|
|
||||||
|
if grep -qE '^AllowUsers' /etc/ssh/sshd_config; then
|
||||||
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
|
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
|
/etc/init.d/ssh reload
|
||||||
|
|
||||||
step_ok "Création des utilisateurs"
|
step_ok "Création des utilisateurs"
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
if [ "$WEB_SERVER" == "apache" ]; then
|
||||||
echo "www-$login: $login" >> /etc/aliases
|
echo "www-$login: $login" >> /etc/aliases
|
||||||
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
|
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
|
||||||
|
elif [ "$WEB_SERVER" == "nginx" ]; then
|
||||||
|
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
|
||||||
|
fi
|
||||||
newaliases
|
newaliases
|
||||||
|
|
||||||
step_ok "Alias mail"
|
step_ok "Alias mail"
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
chmod 750 $HOME_DIR_USER/
|
chmod 750 "$HOME_DIR_USER"/
|
||||||
|
|
||||||
# Répertoires par défaut
|
# Répertoires par défaut
|
||||||
mkdir -p $HOME_DIR_USER/{log,www,awstats}
|
mkdir -p "$HOME_DIR_USER"/{log,www,awstats}
|
||||||
chown $in_login:$in_login $HOME_DIR_USER/www
|
chown "$in_login":"$in_login" "$HOME_DIR_USER"/www
|
||||||
chgrp $in_login $HOME_DIR_USER/{log,awstats}
|
chgrp "$in_login" "$HOME_DIR_USER"/{log,awstats}
|
||||||
chmod 750 $HOME_DIR_USER/{log,www,awstats}
|
chmod 750 "$HOME_DIR_USER"/{log,www,awstats}
|
||||||
|
|
||||||
# Ajout des logs par defaut
|
# Ajout des logs par defaut
|
||||||
touch $HOME_DIR_USER/log/access.log
|
touch "$HOME_DIR_USER"/log/access.log
|
||||||
touch $HOME_DIR_USER/log/error.log
|
touch "$HOME_DIR_USER"/log/error.log
|
||||||
touch $HOME_DIR_USER/log/php.log
|
touch "$HOME_DIR_USER"/log/php.log
|
||||||
chgrp $in_login $HOME_DIR_USER/log/access.log
|
chgrp "$in_login" "$HOME_DIR_USER"/log/access.log
|
||||||
chgrp $in_login $HOME_DIR_USER/log/error.log
|
chgrp "$in_login" "$HOME_DIR_USER"/log/error.log
|
||||||
chown www-$in_login:$in_login $HOME_DIR_USER/log/php.log
|
if [ "$WEB_SERVER" == "apache" ]; then
|
||||||
chmod 640 $HOME_DIR_USER/log/access.log
|
chown www-"$in_login":"$in_login" "$HOME_DIR_USER"/log/php.log
|
||||||
chmod 640 $HOME_DIR_USER/log/error.log
|
fi
|
||||||
chmod 640 $HOME_DIR_USER/log/php.log
|
# 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"
|
step_ok "Création du répertoire personnel"
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
random=$RANDOM
|
if [ -n "$in_quota" ]; then
|
||||||
vhostfile="/etc/apache2/sites-available/$in_login"
|
quota_soft=$(($(echo "$in_quota" |cut -f 1 -d:) * 1024 * 1024))
|
||||||
|
quota_hard=$(($(echo "$in_quota" |cut -f 2 -d:) * 1024 * 1024))
|
||||||
cat $TPL_VHOST | \
|
setquota --remote --user "$in_login" $quota_soft $quota_hard 0 0 /home
|
||||||
sed -e "s/XXX/$in_login/g ; s/SERVERNAME/$in_wwwdomain/ ; s/RANDOM/$random/ ; s#HOME_DIR#$HOME_DIR#" >$vhostfile
|
|
||||||
|
|
||||||
# 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
|
fi
|
||||||
|
|
||||||
a2ensite $in_login >/dev/null
|
|
||||||
|
|
||||||
step_ok "Configuration d'Apache"
|
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
cat $TPL_AWSTATS | \
|
# Create FPM pool on all containers.
|
||||||
sed -e "s/XXX/$in_login/ ; s/SERVERNAME/$in_wwwdomain/ ; s#HOME_DIR#$HOME_DIR#" \
|
for php_version in "${PHP_VERSIONS[@]}"; do
|
||||||
> /etc/awstats/awstats.$in_login.conf
|
if [ "$php_version" = "70" ]; then
|
||||||
chmod 644 /etc/awstats/awstats.$in_login.conf
|
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}
|
||||||
|
|
||||||
VAR=`grep -v "^#" /etc/cron.d/awstats |tail -1 | cut -d " " -f1`
|
listen = ${phpfpm_socket_path}
|
||||||
if [ "$VAR" = "" ] || [ $VAR -ge 59 ]; then
|
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
|
||||||
|
|
||||||
|
sed -e "s/XXX/$in_login/ ; s/SERVERNAME/$in_wwwdomain/ ; s#HOME_DIR#$HOME_DIR#" \
|
||||||
|
< $TPL_AWSTATS > /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
|
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
|
||||||
|
@ -285,36 +536,58 @@ create_www_account() {
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
if [ "$in_dbname" ]; then
|
if [ "$in_dbname" ]; then
|
||||||
echo "CREATE DATABASE \`$in_dbname\` $MYSQL_CREATE_DB_OPTS;" | mysql
|
echo "CREATE DATABASE \`$in_dbname\` $MYSQL_CREATE_DB_OPTS;" | mysql $MYSQL_OPTS
|
||||||
echo "GRANT ALL PRIVILEGES ON \`$in_dbname\`.* TO \`$in_login\`@localhost IDENTIFIED BY '$in_dbpasswd';" | mysql
|
echo "GRANT ALL PRIVILEGES ON \`$in_dbname\`.* TO \`$in_login\`@localhost IDENTIFIED BY '$in_dbpasswd';" | mysql $MYSQL_OPTS
|
||||||
echo "FLUSH PRIVILEGES;" | mysql
|
echo "FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS
|
||||||
|
|
||||||
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"
|
||||||
|
|
||||||
[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
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
cat $TPL_MAIL | \
|
if [ "$in_dbname" ]; then
|
||||||
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#"| \
|
sed -e "
|
||||||
/usr/lib/sendmail -oi -t -f "$CONTACT_MAIL"
|
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#" \
|
||||||
|
< $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
|
||||||
|
|
||||||
|
@ -322,11 +595,75 @@ create_www_account() {
|
||||||
|
|
||||||
############################################################################
|
############################################################################
|
||||||
|
|
||||||
|
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
|
||||||
|
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
|
||||||
|
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")
|
DATE=$(date +"%Y-%m-%d")
|
||||||
|
@ -334,51 +671,226 @@ create_www_account() {
|
||||||
}
|
}
|
||||||
|
|
||||||
op_del() {
|
op_del() {
|
||||||
if [ $# -lt 1 ]; then
|
|
||||||
|
#
|
||||||
|
# Mode interactif
|
||||||
|
#
|
||||||
|
|
||||||
|
if [ $# -eq 0 ]; then
|
||||||
|
echo
|
||||||
|
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
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
else
|
;;
|
||||||
|
?)
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
shift $((OPTIND - 1))
|
||||||
|
if [ $# -gt 0 ] && [ $# -le 2 ]; then
|
||||||
login=$1
|
login=$1
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
dbname=$2
|
dbname=$2
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "----------------------------------------------"
|
||||||
|
echo "Nom du compte : $login"
|
||||||
|
if [ "$dbname" ]; then
|
||||||
|
echo "Base de données MySQL : $dbname"
|
||||||
|
fi
|
||||||
|
echo "----------------------------------------------"
|
||||||
|
echo
|
||||||
|
|
||||||
|
if [ -z "$force_confirm" ]; then
|
||||||
|
echo -n "Confirmer la suppression ? [y/N] : "
|
||||||
|
read -r tmp
|
||||||
|
echo
|
||||||
|
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
|
||||||
|
echo "Annulation..."
|
||||||
|
echo
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Deleting account $login. Continue ?"
|
|
||||||
read
|
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
userdel $login
|
# Crontab dump needs to be done **before** user deletion
|
||||||
userdel www-$login
|
if crontab -l -u "$login"; then
|
||||||
sed -i.bak "/^$login:/d" /etc/aliases
|
crontab -l -u "$login" &> /home/$login/crontab-$(date '+%Y%m%d-%H%M%S').bak
|
||||||
sed -i.bak "/^www-$login:/d" /etc/aliases
|
crontab -r -u "$login"
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i "s/^\(AllowUsers .*\)$login/\1/" /etc/ssh/sshd_config
|
# 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
|
/etc/init.d/ssh reload
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -d "$HOME_DIR/$login" ]; then
|
if [ -d "$HOME_DIR/$login" ]; then
|
||||||
mv -i $HOME_DIR/$login $HOME_DIR/$login.`date '+%Y%m%d-%H%M%S'`.bak
|
mv -i $HOME_DIR/"$login" $HOME_DIR/"$login"."$(date '+%Y%m%d-%H%M%S')".bak
|
||||||
else
|
else
|
||||||
echo "warning : $HOME_DIR/$login does not exist"
|
echo "warning : $HOME_DIR/$login does not exist"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
a2dissite $login
|
if [ -d /etc/letsencrypt/"$login" ]; then
|
||||||
rm /etc/apache2/sites-available/$login
|
rm -r /etc/letsencrypt/"$login"
|
||||||
rm /etc/awstats/awstats.$login.conf
|
fi
|
||||||
sed -i.bak "/-config=$login/d" /etc/cron.d/awstats
|
|
||||||
apache2ctl configtest
|
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
if [ -n "$dbname" ]; then
|
if [ -n "$dbname" ]; then
|
||||||
echo "Deleting mysql DATABASE $dbname and mysql user $login. Continue ?"
|
|
||||||
read
|
|
||||||
|
|
||||||
set -x
|
set -x
|
||||||
echo "DROP DATABASE $dbname; delete from mysql.user where user='$login' ; FLUSH PRIVILEGES;" | mysql
|
echo "DROP DATABASE \`$dbname\`; DROP USER \`$login\`@localhost; FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS
|
||||||
set +x
|
set +x
|
||||||
fi
|
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
|
||||||
|
@ -391,19 +903,55 @@ arg_processing() {
|
||||||
|
|
||||||
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 "$@"
|
||||||
|
;;
|
||||||
|
check-occurence)
|
||||||
|
op_checkoccurencename "$@"
|
||||||
|
;;
|
||||||
|
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
|
usage
|
||||||
|
@ -412,23 +960,99 @@ arg_processing() {
|
||||||
fi
|
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";
|
configlist="$VHOST_PATH/${1}.conf";
|
||||||
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" ] && echo "$configfile" |grep -qvE "/(000-default|default-ssl|evoadmin)\\.conf$"; 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 [ -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
|
if [ "$servername" ] && [ "$userid" ]; then
|
||||||
configid=`basename $configfile`
|
configid=$(basename "$configfile")
|
||||||
echo "$userid:$configid:$servername:$serveraliases"
|
echo "$userid:$configid:$servername:$serveraliases:$size:$quota_soft:$quota_hard:$phpversion:$is_enabled:$is_standard"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -436,29 +1060,150 @@ op_listvhost() {
|
||||||
|
|
||||||
op_aliasadd() {
|
op_aliasadd() {
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
vhost=$1
|
vhost="${1}.conf"
|
||||||
alias=$2
|
alias=$2
|
||||||
|
vhost_file="${VHOST_PATH}/${vhost}"
|
||||||
|
|
||||||
[ -f $VHOST_PATH/$vhost ] && sed -i -e "s/\(ServerName .*\)/\1\n\tServerAlias $alias/" $VHOST_PATH/$vhost
|
if [ -f "${vhost_file}" ]; then
|
||||||
|
sed -i "/ServerName .*/a \\\tServerAlias $alias" "${vhost_file}" --follow-symlinks
|
||||||
|
else
|
||||||
|
echo "VHost file \`${vhost_file}' not found'" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
apache2ctl configtest 2>/dev/null
|
configtest_out=$(apache2ctl configtest)
|
||||||
|
configtest_rc=$?
|
||||||
|
|
||||||
|
if [ "$configtest_rc" = "0" ]; then
|
||||||
/etc/init.d/apache2 force-reload >/dev/null
|
/etc/init.d/apache2 force-reload >/dev/null
|
||||||
|
else
|
||||||
|
echo $configtest_out >&2
|
||||||
|
fi
|
||||||
else usage
|
else usage
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
op_aliasdel() {
|
op_aliasdel() {
|
||||||
if [ $# -eq 2 ]; then
|
if [ $# -eq 2 ]; then
|
||||||
vhost=$1
|
vhost="${1}.conf"
|
||||||
alias=$2
|
alias=$2
|
||||||
|
vhost_file="${VHOST_PATH}/${vhost}"
|
||||||
|
|
||||||
[ -f $VHOST_PATH/$vhost ] && sed -i -e "/ServerAlias $alias/d" $VHOST_PATH/$vhost
|
if [ -f "${vhost_file}" ]; then
|
||||||
|
sed -i -e "/ServerAlias $alias/d" "${vhost_file}" --follow-symlinks
|
||||||
|
else
|
||||||
|
echo "VHost file \`${vhost_file}' not found'" >&2
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
apache2ctl configtest 2>/dev/null
|
configtest_out=$(apache2ctl configtest)
|
||||||
|
configtest_rc=$?
|
||||||
|
|
||||||
|
if [ "$configtest_rc" = "0" ]; then
|
||||||
/etc/init.d/apache2 force-reload >/dev/null
|
/etc/init.d/apache2 force-reload >/dev/null
|
||||||
|
else
|
||||||
|
echo $configtest_out >&2
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
usage
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
else usage
|
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -474,7 +1219,7 @@ op_add() {
|
||||||
|
|
||||||
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 tmp
|
read -r tmp
|
||||||
if validate_login "$tmp"; then
|
if validate_login "$tmp"; then
|
||||||
in_login="$tmp"
|
in_login="$tmp"
|
||||||
fi
|
fi
|
||||||
|
@ -482,11 +1227,11 @@ op_add() {
|
||||||
|
|
||||||
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 -s tmp
|
read -rs 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
|
||||||
|
@ -495,12 +1240,12 @@ op_add() {
|
||||||
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 confirm
|
read -r 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 tmp
|
read -r tmp
|
||||||
|
|
||||||
if [ -z "$tmp" ]; then
|
if [ -z "$tmp" ]; then
|
||||||
tmp=$in_login
|
tmp=$in_login
|
||||||
|
@ -513,11 +1258,11 @@ op_add() {
|
||||||
|
|
||||||
until [ "$in_dbpasswd" ]; do
|
until [ "$in_dbpasswd" ]; do
|
||||||
echo -n "Entrez le mot de passe MySQL (ou vide pour aleatoire) : "
|
echo -n "Entrez le mot de passe MySQL (ou vide pour aleatoire) : "
|
||||||
read -s tmp
|
read -rs 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
|
||||||
|
@ -528,15 +1273,25 @@ op_add() {
|
||||||
|
|
||||||
until [ "$in_wwwdomain" ]; do
|
until [ "$in_wwwdomain" ]; do
|
||||||
echo -n "Entrez le nom de domaine web (ex: foo.example.com) : "
|
echo -n "Entrez le nom de domaine web (ex: foo.example.com) : "
|
||||||
read tmp
|
read -r tmp
|
||||||
if validate_wwwdomain "$tmp"; then
|
if validate_wwwdomain "$tmp"; then
|
||||||
in_wwwdomain="$tmp"
|
in_wwwdomain="$tmp"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ ${#PHP_VERSIONS[@]} -gt 0 ]; then
|
||||||
|
until [ "$in_phpversion" ]; do
|
||||||
|
echo -n "Entrez la version de PHP désirée parmis ${PHP_VERSIONS[*]} : "
|
||||||
|
read -r tmp
|
||||||
|
if validate_phpversion "$tmp"; then
|
||||||
|
in_phpversion="$tmp"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
until [ "$in_mail" ]; do
|
until [ "$in_mail" ]; do
|
||||||
echo -n "Entrez votre adresse mail pour recevoir le mail de creation ($CONTACT_MAIL par défaut) : "
|
echo -n "Entrez votre adresse mail pour recevoir le mail de creation ($CONTACT_MAIL par défaut) : "
|
||||||
read tmp
|
read -r tmp
|
||||||
if [ -z "$tmp" ]; then
|
if [ -z "$tmp" ]; then
|
||||||
tmp="$CONTACT_MAIL"
|
tmp="$CONTACT_MAIL"
|
||||||
fi
|
fi
|
||||||
|
@ -549,7 +1304,7 @@ op_add() {
|
||||||
# Mode non interactif
|
# Mode non interactif
|
||||||
#
|
#
|
||||||
else
|
else
|
||||||
while getopts hyp:m:P:w:l:k:u:g:U: opt; do
|
while getopts hyp:m:P:w:l:k:u:g:U:r:q: opt; do
|
||||||
case "$opt" in
|
case "$opt" in
|
||||||
p)
|
p)
|
||||||
in_passwd=$OPTARG
|
in_passwd=$OPTARG
|
||||||
|
@ -578,6 +1333,12 @@ op_add() {
|
||||||
U)
|
U)
|
||||||
in_wwwuid=$OPTARG
|
in_wwwuid=$OPTARG
|
||||||
;;
|
;;
|
||||||
|
r)
|
||||||
|
in_phpversion=$OPTARG
|
||||||
|
;;
|
||||||
|
q)
|
||||||
|
in_quota=$OPTARG
|
||||||
|
;;
|
||||||
h)
|
h)
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -589,22 +1350,24 @@ op_add() {
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
shift $(($OPTIND - 1))
|
shift $((OPTIND - 1))
|
||||||
if [ $# -ne 2 ]; then
|
if [ $# -ne 2 ]; then
|
||||||
usage
|
usage
|
||||||
exit 1
|
exit 1
|
||||||
else
|
else
|
||||||
in_login=$1
|
in_login=$1
|
||||||
in_wwwdomain=$2
|
in_wwwdomain=$2
|
||||||
validate_login $in_login || exit 1
|
validate_login "$in_login" || exit 1
|
||||||
[ -z "$in_passwd" ] && [ -z "$in_sshkey" ] && in_passwd=`gen_random_passwd`
|
[ -z "$in_passwd" ] && [ -z "$in_sshkey" ] && in_passwd=$(gen_random_passwd)
|
||||||
[ -z "$in_sshkey" ] && ( validate_passwd $in_passwd || exit 1 )
|
[ -z "$in_sshkey" ] && ( validate_passwd "$in_passwd" || exit 1 )
|
||||||
[ -n "$in_dbname" ] && ( validate_dbname $in_dbname || exit 1 )
|
[ -n "$in_dbname" ] && ( validate_dbname "$in_dbname" || exit 1 )
|
||||||
[ -z "$in_dbpasswd" ] && [ -n "$in_dbname" ] && in_dbpasswd=`gen_random_passwd`
|
[ -z "$in_dbpasswd" ] && [ -n "$in_dbname" ] && in_dbpasswd=$(gen_random_passwd)
|
||||||
[ -n "$in_dbname" ] && ( validate_passwd $in_dbpasswd || exit 1 )
|
[ -n "$in_dbname" ] && ( validate_passwd "$in_dbpasswd" || exit 1 )
|
||||||
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
|
||||||
|
[ -n "$in_phpversion" ] && (validate_phpversion "$in_phpversion" || exit 1)
|
||||||
|
[ -n "$in_quota" ] && (validate_quota "$in_quota" || exit 1)
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -617,13 +1380,17 @@ op_add() {
|
||||||
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"
|
||||||
|
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 "Envoi du mail récapitulatif à : $in_mail"
|
||||||
echo "----------------------------------------------"
|
echo "----------------------------------------------"
|
||||||
echo
|
echo
|
||||||
|
|
||||||
if [ -z "$force_confirm" ]; then
|
if [ -z "$force_confirm" ]; then
|
||||||
echo -n "Confirmer la création ? [y/N] : "
|
echo -n "Confirmer la création ? [y/N] : "
|
||||||
read tmp
|
read -r tmp
|
||||||
echo
|
echo
|
||||||
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
|
if [ "$tmp" != "y" ] && [ "$tmp" != "Y" ]; then
|
||||||
echo "Annulation..."
|
echo "Annulation..."
|
||||||
|
@ -638,6 +1405,46 @@ op_add() {
|
||||||
echo
|
echo
|
||||||
}
|
}
|
||||||
|
|
||||||
# Point d'entrée
|
# Some people forget to use the --follow-symlinks flag with sed(1),
|
||||||
arg_processing $*
|
# 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
|
||||||
|
arg_processing "$@"
|
||||||
|
|
72
scripts/web-mail-nginx.tpl
Normal file
72
scripts/web-mail-nginx.tpl
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
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/
|
|
@ -13,9 +13,7 @@
|
||||||
* @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)
|
||||||
|
@ -34,12 +32,21 @@
|
||||||
|
|
||||||
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>
|
||||||
<?php print $form; ?>
|
<?= $form ?>
|
||||||
<p><input type="submit" value="Créer"/></p>
|
<p><input type="submit" value="Créer"/></p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Authentification form
|
* Authentification page
|
||||||
*
|
*
|
||||||
* Copyright (c) 2009 Evolix - Tous droits reserves
|
* Copyright (c) 2009-2022 Evolix - Tous droits reserves
|
||||||
*
|
|
||||||
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
|
|
||||||
*
|
*
|
||||||
|
* @author Evolix <info@evolix.fr>
|
||||||
* @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>
|
||||||
|
* @author and others.
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<br/><br/>
|
<h2>Evoadmin : Connexion</h2>
|
||||||
|
|
||||||
<form method="POST">
|
<form method="POST">
|
||||||
<table width="300" align="center">
|
<table align="center">
|
||||||
<tr>
|
<tr>
|
||||||
<td align="right">Utilisateur : </td>
|
<td align="right">Utilisateur : </td>
|
||||||
<td align="left"><input type="text" name="login" /></td>
|
<td align="left"><input type="text" name="login" /></td>
|
||||||
|
@ -34,7 +34,10 @@
|
||||||
if (!empty($error)) {
|
if (!empty($error)) {
|
||||||
?>
|
?>
|
||||||
<tr>
|
<tr>
|
||||||
<td colspan="2" class="auth-error">Identifiants invalides. Veuillez ré-essayer</td>
|
<td colspan="2" class="auth-error">
|
||||||
|
Identifiants invalides.
|
||||||
|
Veuillez ré-essayer
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
|
42
tpl/dbadmin.tpl.php
Normal file
42
tpl/dbadmin.tpl.php
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
<?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"> %s</td>', preg_replace("/'/", "", $db_info['owner']));
|
||||||
|
printf('<td align="left"> %s</td>', $db_info['database']);
|
||||||
|
print '</tr>';
|
||||||
|
} ?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<?php
|
||||||
|
} else {
|
||||||
|
print '<div class="alert alert-info" role="alert">Aucune base existante !</div>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</div>
|
|
@ -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 - Powered by Evolix</title>
|
<title>Evoadmin-web - 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,13 +31,22 @@
|
||||||
<body>
|
<body>
|
||||||
|
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<h1 id="top">EvoAdmin
|
<h1 id="top">Evoadmin-web
|
||||||
<?php
|
<?php
|
||||||
if(!empty($_SESSION['user'])) {
|
if(!empty($_SESSION['user'])) {
|
||||||
print ' - '.$_SESSION['user'];
|
print ' v'.$_SESSION['cli_version'].' - '.$_SESSION['user'];
|
||||||
}
|
|
||||||
if(is_superadmin()) {
|
if(is_superadmin()) {
|
||||||
print ' (Administrateur)';
|
print ' (Administrateur)';
|
||||||
}
|
}
|
||||||
|
if (is_mcluster_mode()) {
|
||||||
|
if (!empty($_SESSION['cluster'])) {
|
||||||
|
print ' - '.$_SESSION['cluster'];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print ' - Aucun cluster sélectionné !';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
</h1>
|
</h1>
|
||||||
|
|
|
@ -13,9 +13,23 @@
|
||||||
* @version 1.0
|
* @version 1.0
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
require_once EVOADMIN_BASE . '../evolibs/Form.php';
|
||||||
|
|
||||||
|
if (is_mcluster_mode()) {
|
||||||
|
echo '<p>Bienvenue, sélectionnez le cluster que vous voulez administrer,
|
||||||
|
puis utilisez le menu ci-dessus pour administrer votre compte.</p>';
|
||||||
|
|
||||||
|
print "<form name=\"form-add\" id=\"form-add\" action=\"\" method=\"POST\">";
|
||||||
|
print " <fieldset>";
|
||||||
|
print " <legend>Choisissez un cluster</legend>";
|
||||||
|
print $form;
|
||||||
|
print " <p><input type=\"submit\" value=\"Ok\"/></p>";
|
||||||
|
print " </fieldset>";
|
||||||
|
print "</form>";
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo '<p>Bienvenue, utilisez le menu ci-dessus pour administrer votre compte.</p>';
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<p>
|
|
||||||
Bienvenue, utilisez le menu ci-dessus pour administrer votre compte.
|
|
||||||
</p>
|
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,9 @@
|
||||||
<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/>
|
||||||
|
|
36
tpl/webadmin-delete.tpl.php
Normal file
36
tpl/webadmin-delete.tpl.php
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
<?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>
|
|
@ -16,13 +16,12 @@
|
||||||
<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/edit/%s?add">Ajouter un alias</a></p>', $domain);
|
printf('<p><a href="/webadmin/%s/alias/add/">Ajouter un alias</a></p>', $domain);
|
||||||
print "</center>";
|
print "</center>";
|
||||||
}?>
|
}?>
|
||||||
|
|
||||||
|
@ -39,10 +38,10 @@
|
||||||
<?php
|
<?php
|
||||||
for ( $i=0; $i < count($alias_list); ++$i ) {
|
for ( $i=0; $i < count($alias_list); ++$i ) {
|
||||||
print '<tr>';
|
print '<tr>';
|
||||||
printf('<td><a href="http://%s">http://%s</a></td>',
|
printf('<td>%s</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/edit/%s?del=%s">Supprimer</a></td>',
|
printf('<td><a href="/webadmin/%s/alias/delete/%s/">Supprimer</a></td>',
|
||||||
$domain, $alias_list[$i]['alias']);
|
$domain, $alias_list[$i]['alias']);
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
} ?>
|
} ?>
|
||||||
|
@ -53,12 +52,10 @@
|
||||||
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/edit/%s?add">Ajouter un alias</a></p>', $domain);
|
printf('<p><a href="/webadmin/%s/alias/add/">Ajouter un alias</a></p>', $domain);
|
||||||
print "</center>";
|
print "</center>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
|
58
tpl/webadmin-itk.tpl.php
Normal file
58
tpl/webadmin-itk.tpl.php
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
<?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>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
53
tpl/webadmin-letsencrypt.tpl.php
Normal file
53
tpl/webadmin-letsencrypt.tpl.php
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
tpl/webadmin-php.tpl.php
Normal file
26
tpl/webadmin-php.tpl.php
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
<?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>
|
49
tpl/webadmin-servername.tpl.php
Normal file
49
tpl/webadmin-servername.tpl.php
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
<?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>";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
|
@ -15,26 +15,45 @@
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<h2>Domaines</h2>
|
<h2>Liste des comptes web</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>Propriétaire</th>';
|
print '<th>Virtual Host</th>';
|
||||||
} ?>
|
} ?>
|
||||||
<th>Domaine</th>
|
<th>Servername</th>
|
||||||
|
<?php if(is_superadmin()) {
|
||||||
|
print '<th>Alias</th>';
|
||||||
|
}
|
||||||
|
if($conf['quota']) {
|
||||||
|
print '<th> Utilisé </th>';
|
||||||
|
print '<th> Soft </th>';
|
||||||
|
print '<th> Hard </th>';
|
||||||
|
print '<th> Occupation </th>';
|
||||||
|
}
|
||||||
|
if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) {
|
||||||
|
print '<th> PHP </th>';
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<th> Actif ? </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>
|
||||||
|
<th>Mail</th>
|
||||||
<th>Replication</th>
|
<th>Replication</th>
|
||||||
<th>Master</th>
|
<th>Master</th>
|
||||||
<th>Slave</th>
|
<th>Slave</th>
|
||||||
<?php } else
|
<?php } ?>
|
||||||
print('<th>Alias</th>');
|
</tr>
|
||||||
?>
|
|
||||||
<tr>
|
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
<?php foreach($vhost_list as $vhost_info) {
|
<?php foreach($vhost_list as $vhost_info) {
|
||||||
|
@ -42,43 +61,72 @@
|
||||||
if(is_superadmin()) {
|
if(is_superadmin()) {
|
||||||
printf('<td>%s</td>', $vhost_info['owner']);
|
printf('<td>%s</td>', $vhost_info['owner']);
|
||||||
}
|
}
|
||||||
printf('<td><a href="http://%s">http://%s</a></td>',
|
printf('<td>%s</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['replication']))
|
if (empty($vhost_info['mail']))
|
||||||
printf('<td bgcolor="#696969" />');
|
printf('<td bgcolor="#696969" />');
|
||||||
|
else if ($vhost_info['mail'] == 'gmail')
|
||||||
|
printf('<td><img src="/img/gmail.gif" alt="Gmail" /></td>');
|
||||||
|
else printf('<td><img src="/img/evolix.gif" alt="Evolix" /></td>');
|
||||||
|
|
||||||
|
if (empty($vhost_info['replication']))
|
||||||
|
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']);
|
||||||
|
}
|
||||||
|
|
||||||
|
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><a href="/webadmin/edit/%s">Lister/Modifier</a></td>',
|
printf('<td>');
|
||||||
$vhost_info['owner']);
|
if (!in_array($vhost_info['owner'], $_SESSION['non_standard'])) {
|
||||||
|
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>');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
|
||||||
if (empty($vhost_info['server_alias']))
|
|
||||||
printf('<td bgcolor="#696969"/>');
|
|
||||||
else
|
|
||||||
printf('<td>%s</td>', $vhost_info['server_alias']);
|
|
||||||
}
|
|
||||||
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>';
|
||||||
|
|
Loading…
Reference in a new issue