Compare commits

...

270 commits
ssl ... master

Author SHA1 Message Date
Ludovic Poujol 3400434f90 Merge pull request 'Bump version & Debian 12 patch' (#95) from unstable into master
Reviewed-on: #95
2024-04-22 10:41:13 +02:00
Ludovic Poujol a7c1af3d83
Update changelog for release 2024-04-16 18:02:46 +02:00
Ludovic Poujol 188e63376d
Bump version 2024-04-16 18:01:24 +02:00
Ludovic Poujol a30ba3337b
Update CHANGELOG.md
* web-add.sh: Fix ssh group membership (#94)
2024-04-16 17:59:01 +02:00
Ludovic Poujol b014f1584a Merge pull request 'Fix ssh group membership.' (#94) from fix-ssh-memebership into unstable
Reviewed-on: #94
2024-04-16 17:55:08 +02:00
Brice Waegeneire 99741826f6 Fix ssh group membership.
We now use split SSH configuration files, so the user was never a member
of the ssh group on newly installed systems. This change don't modify
the SSH configuration of new systems since evolinux-ssh members' are
already allowed to connect by SSH.
2024-04-03 16:28:57 +02:00
Mathieu Trossevin 5a22490dc8 Merge pull request 'Fixes' (#90) from unstable into master
Reviewed-on: #90
2023-12-06 10:49:02 +01:00
William Hirigoyen 95108897b0 Fix remaining test 2023-12-01 17:15:35 +01:00
Mathieu Trossevin fd0f03ab05 Merge pull request 'fix(letsencrypt): check for false as to avoid TypeError' (#84) from fix-letsencrypt into unstable
Reviewed-on: #84
2023-11-30 16:36:16 +01:00
whirigoyen 93c9e450ff Merge pull request 'sendmail_path in LXC, and better op_del' (#85) from unstable into master
Reviewed-on: #85
Reviewed-by: Mathieu Trossevin <mtrossevin@noreply.gitea.evolix.org>
2023-11-30 15:53:07 +01:00
Mathieu Trossevin 2b6b76b78d
Update changelog 2023-11-17 14:39:42 +01:00
Mathieu Trossevin 21eef58a96 Merge branch 'unstable' into fix-letsencrypt 2023-11-17 14:34:16 +01:00
Mathieu Trossevin 6951d1fd33 Merge branch 'master' into unstable 2023-11-16 11:04:29 +01:00
William Hirigoyen 0dfb19faea Remove undue commit 2023-11-13 14:29:55 +01:00
William Hirigoyen 8e15676d05 Improve op_del improvement 2023-11-10 11:11:52 +01:00
William Hirigoyen f5fe462248 Revert "Fix missing ITK admin link for multi PHP"
This reverts commit 2fd65724f7.
2023-11-10 10:49:29 +01:00
William Hirigoyen 964f710897 Revert "Remove extra }"
This reverts commit c385c102c5.
2023-11-10 10:49:16 +01:00
William Hirigoyen c385c102c5 Remove extra } 2023-11-09 17:21:33 +01:00
William Hirigoyen 2fd65724f7 Fix missing ITK admin link for multi PHP 2023-11-09 17:08:39 +01:00
William Hirigoyen 7d8704cd25 Fix sendmail_path hostname (missing domain / FQDN) 2023-11-09 12:01:14 +01:00
William Hirigoyen 72e39f297e Prevent op_del to fail and able to remove web account when part of it is already removed 2023-11-09 11:31:16 +01:00
William Hirigoyen 2e8619e5e6 Add sendmail_path and open_basedir in LXC PHP pool configs 2023-11-08 12:03:14 +01:00
Mathieu Trossevin 9419242465
fix(letsencrypt): check for false as to avoid TypeError 2023-10-31 10:04:02 +01:00
bwaegeneire e76ea90d89 Merge pull request 'Add support for php8.2' (#81) from unstable into master
Reviewed-on: #81
2023-03-31 13:11:36 +02:00
Brice Waegeneire a7f718c073 Add support for php8.2 2023-03-31 13:07:39 +02:00
Ludovic Poujol f77ce6e590 Release 23.02 2023-02-20 11:52:13 +01:00
Ludovic Poujol d2365e133b Big update of projet reame
Translated to english, changed contribution guidelines (same as ansible-roles)
Removed old TODO/INSTALL file
2023-02-20 11:19:08 +01:00
Ludovic Poujol fbc48755b0 Introducing a changelog (filled with 2023 changes) 2023-02-20 10:44:43 +01:00
Ludovic Poujol 63dfa3af99 web-add.sh > Correct deletion order
Closes #76
2023-02-20 10:34:41 +01:00
Ludovic Poujol 577a4463ad Account deletion > Use mysql "DROP USER"
Instead of messing directly with mysql internal tables
Closes #78
2023-02-15 12:04:59 +01:00
Ludovic Poujol 66c159a625 Display the web-add.sh version 2023-02-15 11:36:25 +01:00
Ludovic Poujol 77f5076c88 Move common.php outside of the DocumentRoot 2023-02-15 11:35:21 +01:00
William Hirigoyen ad68e298dd VérCheck chars [:/] are not in the domain name (in case of confusion with URL) 2022-12-09 15:30:14 +01:00
Ludovic Poujol 68799f7e5f Correction bug suppression compte 2022-11-21 17:25:19 +01:00
Ludovic Poujol ebb4f1c20c ftpadmin.sh - Correction regression listing des comptes introduite par d6c39be117 2022-11-21 17:15:47 +01:00
Ludovic Poujol f65dd98bb1 Web-add.sh: Add a version number (+ command to fetch it) 2022-11-10 15:58:15 +01:00
William Hirigoyen 67d0c45d79 Fix bug introduced in 9913579bb0 (MariaDB does not support backtics in where clause). 2022-11-08 17:30:05 +01:00
William Hirigoyen 9913579bb0 Fix drop database when contains dash 2022-10-31 14:40:19 +01:00
David Prevot e257ee242b web-add generate-ssl-certificate: false option should be documented as is
As fb78d2a9ed, but the other way around: update only the documentation
instead of the code, so that existing use does not change.
2022-07-19 16:39:20 +02:00
David Prevot 2301b0cba5 web-add generate-ssl-certificate: improve FALSE option documentation 2022-07-19 14:24:33 +02:00
David Prevot fb78d2a9ed web-add generate-ssl-certificate: FALSE option should match documented case 2022-07-19 14:18:04 +02:00
Ludovic Poujol 66ceacd918 Make the change on the login mechanism compatible with old configurations 2022-07-07 11:22:47 +02:00
Ludovic Poujol d746aa445e Change in the login mechanism
Now use passwords hashed & salted. Validate with PHP's password_verify() function

Password hashes can be generated with :
* mkpasswd --method=sha-512
* PHP's password_hash()
2022-07-05 11:25:37 +02:00
Ludovic Poujol 143af65357 Hotfix for web interface to behave correctly 2022-07-04 14:34:41 +02:00
Ludovic Poujol 96ffc58cc4 Clear some warnings about undefined vars 2022-07-01 16:13:49 +02:00
William Hirigoyen (Evolix) 93629b51fb Fix bug introduced in f2f115608a (op del fails when user has no crontab) 2022-05-11 14:39:00 +02:00
Brice Waegeneire d63046b227 Add support for php8.1 2022-02-22 15:16:22 +01:00
Ludovic Poujol f2f115608a Dump & remove user crontab on account deletion
closes #37
2022-02-17 11:12:55 +01:00
Ludovic Poujol ef5bbbeba7 Fix behaviour when there is only one php version
closes #74
2022-02-17 10:40:00 +01:00
William Hirigoyen (Evolix) d6c39be117 #62716 : Corrections et améliorations ftpadmin.sh 2021-12-23 15:51:55 +01:00
William Hirigoyen (Evolix) 5cd6a6f046 Test if user www-login exists before deleting (else, the deletion fails) 2021-12-02 10:16:12 +01:00
Brice Waegeneire 0709747a1e web-add.sh script now handles php 8.0 containers 2021-10-05 10:13:12 +02:00
Brice Waegeneire 360929ee96 web-add.sh script now handles php 8.0 containers 2021-10-05 10:06:14 +02:00
Brice Waegeneire e3dc97d6d4 delete users even though it has some processes running 2021-09-22 10:35:10 +02:00
Ludovic Poujol ae30498030 set a uid for the user at login for ftp filtering 2021-04-28 16:21:29 +02:00
Tristan PILAT 372b00101d web-add.sh script now handles php 7.4 containers 2021-04-15 11:11:55 +02:00
Ludovic Poujol 7499f0222e Reorder lines in template fpm config for better readability 2021-02-23 11:07:29 +01:00
Ludovic Poujol 4f8b0b19fe generate longer password by default 2021-02-22 16:22:31 +01:00
Ludovic Poujol 2906ba47f1 Add (random) status path php 2021-02-22 16:12:21 +01:00
Ludovic Poujol e2acb4e9d1 web-add.sh - Add .conf at the config name for a2ensite/a2dissite
Fixes #70
2021-02-10 15:21:04 +01:00
Ludovic Poujol 234ac67634 Fix op_checkoccurencename() in web-add.sh (again)
I had it wrong (again) in 283d0bccad :-(

https://www.youtube.com/watch?v=TMy6X5cQul8
2019-10-14 10:21:05 +02:00
Ludovic Poujol 283d0bccad Fix op_checkoccurencename() in web-add.sh (again)
I had it wrong in 9523fff658 :/
2019-10-02 17:40:01 +02:00
Ludovic Poujol 6438732ea4 Add missing break.... 2019-09-06 16:26:14 +02:00
Ludovic Poujol 9523fff658 Fix op_checkoccurencename() in web-add.sh
Ensure that we can add foo.net while having www.foo.net somewhere in out 
config files
2019-08-26 11:20:44 +02:00
Ludovic Poujol f7659cee6d Fix IncludeOptional that can throw syntax errors in some cases.
With Apache < 2.4.30, IncludeOptional will throw syntax errors if the 
file designated without any pattern globbing is absent.
We circumvent that with a silly pattern.
2019-08-21 12:05:37 +02:00
Nicolas Roman b148cf1176 Merge branch 'letsencrypt' of evolix/evoadmin-web into master 2019-07-26 11:15:48 +02:00
Nicolas Roman 3736f7ec32 display expiration date of cert and included domains directly when clicking the letsencrypt link 2019-07-25 11:37:57 +02:00
Nicolas Roman a0f41b4b69 Merge branch 'del-letsencrypt' of evolix/evoadmin-web into master 2019-07-24 16:30:43 +02:00
Nicolas Roman 5cd4cff029 remove matching letsencrypt folder when deleting an account 2019-07-24 16:25:16 +02:00
Nicolas Roman b339ca0fb9 display included and non included domain(s) before the cert renew 2019-07-19 14:38:24 +02:00
Nicolas Roman f3fa182dc7 delete methods updating the vhost after cert installation is completed 2019-07-17 17:20:32 +02:00
Nicolas Roman 4b5a020993 port 443 by default in vhost template 2019-07-17 17:11:52 +02:00
Nicolas Roman c5c1648a58 delete previous cert if it already exists before invoking evoacme 2019-07-17 15:38:59 +02:00
Nicolas Roman 7d026c907b add optional SSL configuration by default in vhost 2019-07-15 17:44:41 +02:00
Nicolas Roman 283f76540a uses stream_socket_client instead of fopen 2019-07-15 17:08:47 +02:00
Nicolas Roman c218aebaae bugfixes for the evoacme part 2019-07-15 17:06:50 +02:00
Nicolas Roman 4eaf3ad6d1 fix acme-challenge subfolder creation 2019-07-11 16:54:21 +02:00
Nicolas Roman 78d0293b44 create the acme-challenge subfolder correctly for the HTTP challenge 2019-07-11 15:24:17 +02:00
Nicolas Roman 27b449fd98 check that the non_standard domain is not already in the session variable 2019-07-11 14:19:09 +02:00
Nicolas Roman 8fe671097d tweak success message for cert installation 2019-07-10 16:59:36 +02:00
Nicolas Roman 839efa6fe9 generateSSLCertificate and setSSLPortVhost methods added 2019-07-10 16:57:34 +02:00
Nicolas Roman 37e5ca6484 generate-ssl-certificate and update-ssl-configuration methods for web-add.sh 2019-07-10 16:56:50 +02:00
Nicolas Roman 9c9ffe1b53 check if the domain IP correspond to the server IP 2019-07-10 16:56:13 +02:00
Nicolas Roman 1b4231e1a9 make-csr function and confirmation button when warning is displayed 2019-07-09 18:07:47 +02:00
Nicolas Roman 1cf62beb55 retrieve the correct aliases and servername from a specified vhost 2019-07-04 18:00:59 +02:00
Nicolas Roman 3ab7a01077 new warning rule with orange color for span element 2019-07-04 15:55:38 +02:00
Nicolas Roman c4a6b1f069 errors handling for SSL check with the issuer, validity date and included domains 2019-07-04 15:55:10 +02:00
Nicolas Roman 1fc8a3e322 add keys to return array for parseCertificate method 2019-07-04 15:53:35 +02:00
Nicolas Roman 43318dc09a add https prefix to getCertificate method 2019-07-04 15:52:55 +02:00
Nicolas Roman 3b9a534253 filter empty items from session variable of domains 2019-07-04 15:51:58 +02:00
Nicolas Roman 69936f67db retrieve SSL cert and parse it, check the issuer, the expiration date and the SAN 2019-07-03 18:18:27 +02:00
Nicolas Roman 2737edbc11 update let's encrypt button name 2019-06-07 15:25:34 +02:00
Nicolas Roman d7f0a5e36c change error handling for let's encrypt checks 2019-06-07 15:25:15 +02:00
Nicolas Roman 15faf3dfdc add isEvoacmeInstalled function 2019-06-07 15:24:38 +02:00
Nicolas Roman f6cfe14cdc add createFileHttpChallenge and deleteFileHttpChallenge functions 2019-06-07 15:23:39 +02:00
Nicolas Roman bd6d70fbfe change http challenge filename 2019-06-07 15:22:42 +02:00
Nicolas Roman b25639c3aa add manage-http-challenge-file function 2019-06-07 14:10:07 +02:00
Nicolas Roman 320a229d4f separate view and controller logic 2019-06-07 11:49:11 +02:00
Nicolas Roman 58dda79c6a add letsencrypt link in webadmin page 2019-06-07 11:48:09 +02:00
Nicolas Roman 4a137ae821 add h3 error styling 2019-06-07 11:46:01 +02:00
Nicolas Roman b44a70f089 fix CURLOPT_REDIR_PROTOCOLS values 2019-06-07 10:43:45 +02:00
Nicolas Roman 2fff30a658 first draft webadmin-letsencrypt tpl 2019-06-06 18:20:27 +02:00
Nicolas Roman 6b8128e861 move FQDN syntax to checkDNSValidity function 2019-06-06 18:18:09 +02:00
Nicolas Roman 2193307e14 first draft webadmin-letsencrypt.php 2019-06-06 18:16:52 +02:00
Nicolas Roman 4cde233804 regroup webadmin rules 2019-06-06 18:15:30 +02:00
Nicolas Roman 12b907ea63 add checkDNSValidity function 2019-06-06 15:41:58 +02:00
Nicolas Roman 4a14333d41 first draft library letsencrypt 2019-06-06 14:51:34 +02:00
Nicolas Roman 84a821d58c Merge branch 'vhost-delete' of evolix/evoadmin-web into master 2019-06-05 17:24:28 +02:00
Nicolas Roman 634a18d1cb rebase master 2019-06-05 17:20:34 +02:00
Nicolas Roman 44b4ac2f5e add .idea folder to gitignore 2019-06-05 16:34:16 +02:00
Nicolas Roman a907137e27 block non-standard vhost modification 2019-06-05 16:34:16 +02:00
Nicolas Roman ad452aad6a delete list-servername function 2019-06-05 16:33:37 +02:00
Nicolas Roman b1bab0b40c normalize add-alias with del-alias 2019-06-05 16:33:23 +02:00
Nicolas Roman 5a738c4e2e revert multiple virtualhosts mgmt for ITK 2019-06-05 16:33:23 +02:00
Nicolas Roman 1ee7221b19 normalize text 2019-06-05 16:31:16 +02:00
Nicolas Roman 1ffa0ef4e7 normalize title names 2019-06-05 16:30:21 +02:00
Nicolas Roman bb17afd5fc added delete link 2019-06-05 16:29:19 +02:00
Nicolas Roman 6f7fe19046 added delete webpage 2019-06-05 16:29:19 +02:00
Nicolas Roman ad3c31fb96 added force-confirm option for del script 2019-06-05 16:29:19 +02:00
Nicolas Roman 7a0d307f23 first draft 2019-06-05 16:29:19 +02:00
emorino a3c67afb2a typo 2019-04-26 09:53:10 +02:00
emorino c0fb7a5d74 Ajout configuration /etc/hosts pour install paquet ssmtp 2019-04-26 09:52:05 +02:00
Ludovic Poujol a200ccfdeb Ensure a password can't contain a "/" 2019-04-23 18:16:33 +02:00
Ludovic Poujol d63150c4ce Add missing escapeshellarg() in account creation 2019-04-23 18:16:07 +02:00
Ludovic Poujol 7b5868db38 README.md : Ajout exemple /usr/local/bin/exec73 2019-04-12 12:05:07 +02:00
Nicolas Roman cd6abd008d Merge branch 'route-naming' of evolix/evoadmin-web into master 2019-04-08 17:17:36 +02:00
Ludovic Poujol d00ecea964 web-add.sh - Ensure the FPM pools uses the www-XXX user 2019-04-02 15:15:51 +02:00
Nicolas Roman c9ed53d7dd php url changed 2019-04-01 18:10:53 +02:00
Nicolas Roman 6d0a456de9 alias url changed 2019-04-01 17:09:05 +02:00
Nicolas Roman 6ef1c9fcf7 refactoring webadmin-itk 2019-04-01 16:14:48 +02:00
Nicolas Roman 99ac46f671 itk url changed 2019-04-01 15:41:59 +02:00
Nicolas Roman fde162d679 servername url changed 2019-04-01 15:13:28 +02:00
Ludovic Poujol e0f8d6ade1 Command fixes in README.md 2019-03-29 15:58:28 +01:00
Ludovic Poujol 2aa7a7a565 Only display the PHP version change link on multi-php install
(Also means the ITK setting doesn't matter and should not be displayed)
2019-03-29 15:56:35 +01:00
Ludovic Poujol 1331bb96b4 Fix is_multiphp() always returning false 2019-03-29 15:55:43 +01:00
Ludovic Poujol 93608a4147 Merge branch 'features/servername' of evolix/evoadmin-web into master 2019-03-28 15:23:37 +01:00
Jérémy Lecour 7faf647185 replace chained conditionals by regular if/else + configtest before reload 2019-03-27 15:42:53 +01:00
Ludovic Poujol 128db07700 The php version field should be mandatory 2019-03-27 14:58:56 +01:00
Ludovic Poujol 256baadb85 Add PHP version update interface when running in multiphp mode 2019-03-27 14:08:03 +01:00
Ludovic Poujol 369415b5f5 Ensure SelectFormField behave properly in some edge cases 2019-03-27 14:08:03 +01:00
Nicolas Roman d3e5cc7b4c fix case when using multiple time disable-user-itk and enable-user-itk 2019-03-26 17:46:31 +01:00
Ludovic Poujol 29b92647a7 Refactor the domain and alias checks done at account creation 2019-03-26 16:59:12 +01:00
Ludovic Poujol b3ec773c64 Ensure that check_occurence_name say false if an empty string is given
Also add some comments & fix code indent
2019-03-26 16:37:26 +01:00
Nicolas Roman e15e03c36b enhance enable/disable for itk 2019-03-26 15:42:35 +01:00
Nicolas Roman fc3fe6bd15 cleaning code + add links to navigate to new pages 2019-03-26 15:42:35 +01:00
Nicolas Roman 89858a6bbd first draft itk mgmt 2019-03-26 15:42:35 +01:00
Nicolas Roman 6f0106d4d0 implement check_occurence_name on account creation 2019-03-26 15:41:53 +01:00
Nicolas Roman 0bfe7a2aac update check_occurence_name function to work with multiple aliases 2019-03-26 15:41:53 +01:00
Nicolas Roman 2f25655038 using better var names for check occurence return code 2019-03-26 15:41:53 +01:00
Nicolas Roman cf4d066f0e call function check_occurence for alias and servername 2019-03-26 15:41:53 +01:00
Nicolas Roman 24c4e4236d move the check-occurence logic to a function 2019-03-26 15:41:53 +01:00
Nicolas Roman bbada41dd5 Added check-occurence for alias creation 2019-03-26 15:41:53 +01:00
Nicolas Roman 4153145c5d Added check-occurence for servername update 2019-03-26 15:41:53 +01:00
Nicolas Roman fed8a1fc84 Added function to search occurence of given name in vhosts 2019-03-26 15:41:53 +01:00
Nicolas Roman ce66f0b9b8 enabled field verification for ServerName 2019-03-26 15:41:53 +01:00
Nicolas Roman 28149ed229 change ServerName for a specific vhost 2019-03-26 15:41:53 +01:00
Nicolas Roman 38308afcf7 list servername and relace previous servername with new one 2019-03-26 15:41:53 +01:00
Nicolas Roman d5f4e27840 option for hidden input in DomainInputFormField class 2019-03-26 15:41:53 +01:00
Nicolas Roman f90b127a95 list servername linked to file conf 2019-03-26 15:41:53 +01:00
Nicolas Roman 20aeb60cda using DomainInputFormField for ServerName update field 2019-03-26 15:41:53 +01:00
Nicolas Roman 7e02e50047 update ServerName from web interface 2019-03-26 15:41:53 +01:00
Nicolas Roman 794defa907 retrieve first ServerName and change it with the new one in all the conf file 2019-03-26 15:41:52 +01:00
Nicolas Roman fdce16652a allow default value for field 2019-03-26 15:41:52 +01:00
Nicolas Roman 6e8ea737de replace ServerName inside Rewrite rules 2019-03-26 15:41:52 +01:00
Nicolas Roman b6fcb25b3b added servernameupdate function 2019-03-26 15:41:52 +01:00
Ludovic Poujol 15f4918258 Fix a regression itroduced by AlphaNumericalTextInputFormField 2019-03-26 15:31:45 +01:00
Benoît S. 0ae9645f88 Merge branch 'bind-add-use-perl-grep' of evolix/evoadmin-web into master 2019-03-22 09:41:02 +01:00
Ludovic Poujol 34c7c5dc22 Don't compute spaces when quota is disabled
Also fix code ident
2019-03-21 17:41:11 +01:00
Benoît S. 9209aae0d1 bind-add-ng: grep -E is not working for tabulations
We need to use grep -P, to use pcrepattern(3).
2019-03-21 17:08:54 +01:00
Ludovic Poujol 6b1fa94da9 Ensuring that account name and db name only contain alphanumerical chars (and - _ )
With new type of form field : AlphaNumericalTextInputFormField
2019-03-21 16:38:06 +01:00
Ludovic Poujol a9b130eaca Compléments README.md 2019-03-21 14:17:00 +01:00
Ludovic Poujol 87c08696e3 web-add.sh: Ensure op_setphpversion even when there tabs or no spaces 2019-03-21 10:59:59 +01:00
Ludovic Poujol 468f929d18 Merge branch 'features/validate-domains' of evolix/evoadmin-web into master
closes #24
closes #18
closes #14
2019-03-20 16:40:02 +01:00
Ludovic Poujol 501f6ebbab Better regex for domain matching 2019-03-19 19:11:58 +01:00
Ludovic Poujol 3469dcfcd5 New class DomainListInputFormField for alias list validation upon account creation 2019-03-19 18:38:17 +01:00
Ludovic Poujol 93aeb193ee Use DomainInputFormField for alias creation 2019-03-19 18:27:24 +01:00
Ludovic Poujol 1641aee38c Use our new DomainInputFormField for account creation 2019-03-19 18:14:21 +01:00
Ludovic Poujol d9dea033a9 New class DomainInputFormField
Create a input that validates a domain name.
2019-03-19 18:13:48 +01:00
Ludovic Poujol 7f1af3a8fe Ensure that dbadmin.sh is executable 2019-03-18 15:35:16 +01:00
Ludovic Poujol fe8a1400a5 Rendre le lien de modifications des alias plus explicite 2019-03-18 12:00:14 +01:00
Ludovic Poujol 4005c23772 Liste des vhosts: Afficher "Activé/Désactivé" à place de 1/0 2019-03-18 11:58:38 +01:00
Ludovic Poujol cd9e1af13d Complément manquant : activation de proxy_fcgi en mode multi-php
Voir #46
2019-03-18 11:11:24 +01:00
Tristan 2a183351db Merge branch 'master' of https://gitea.evolix.org/evolix/evoadmin-web 2019-03-15 16:44:47 +01:00
Ludovic Poujol 52c7cfb888 Support express de containers PHP7.3
(pas très joli... oui :/)
2019-03-15 16:44:42 +01:00
Tristan b296421022 Add PHP7.3 instructions 2019-03-15 16:43:47 +01:00
Ludovic Poujol 614de20c34 Fix deletion using wrong path 2019-03-15 16:42:13 +01:00
Ludovic Poujol f669c3f793 Remove the width on the login page 2019-03-15 11:55:15 +01:00
Tristan b1d602234f Attention l'umask ! 2019-03-14 11:24:59 +01:00
Tristan d9bdfe8ff9 Rajout de la partie concernant le montage de /home 2019-03-14 11:24:12 +01:00
Ludovic Poujol 1ffd61e967 Corrections README.md 2019-03-08 11:45:44 +01:00
Tristan PILAT 2c68341986 Add LXC installation détails part 2019-03-05 11:06:15 +01:00
Victor LABORIE 305c9c0104 Documentation for using multi PHP versions 2019-03-04 15:58:25 +01:00
Ludovic Poujol 249a3ac1e9 Fix: web-add.sh not properly listing vhosts' aliases 2019-02-28 18:01:46 +01:00
Ludovic Poujol 2935b771cb Fix #19 - Do not enforce md5 for password 2019-02-28 16:19:54 +01:00
Ludovic Poujol a52846c977 Add a vhost counter
Fix #40
2019-02-28 15:45:25 +01:00
Ludovic Poujol 0cb7c54855 Vagrantfile: Add a symlink to /usr/share/scripts/evoadmin, to ensure the latests scripts are used 2019-02-28 15:40:16 +01:00
Ludovic Poujol 3a19d14e3a Introducing a Vagrantfile for testing \o 2019-02-28 13:55:47 +01:00
Ludovic Poujol ead51deca6 Honor the request scheme when redirecting the user 2019-02-28 13:53:00 +01:00
Gregory Colpart 2125055409 Fix when multiples SetHandler lines in VHOST file 2019-02-21 02:31:04 +01:00
Victor LABORIE 6ba1fbcb6e Evoadmin-web is now under AGPLv3 license 2018-12-20 11:47:24 +01:00
Patrick Marchand ea359880cc New check-vhosts command for web-add.sh
Checks whether the enabled vhosts are all symbolic links, also offers the -f flag to fix any problems automatically.
2018-12-13 23:29:06 +01:00
Patrick Marchand 21f5f011da Fixed mistake with getopts(1) in web-add.sh 2018-12-13 13:21:13 -05:00
Ludovic Poujol cc08313e1f Do not display evoadmin in the ftp account creation form 2018-12-11 16:09:08 +01:00
Ludovic Poujol 8429351213 Do not list evoadmin in the vhost list
Fixes #34
2018-12-11 15:30:06 +01:00
Patrick Marchand c135807010 Changed API for web-add.sh fix-vhosts
check-vhosts now only applies changes when it is passed the -f flag,
otherwise it simply lists the suggested fixes.
2018-12-04 11:25:45 -05:00
Patrick Marchand 53335ee4ef Apply first and third benpro review of web-add fix command
Simplify sed(1) command by getting rid of echo(1)

Use a2ensite(1) instead of ln(1) to link vhosts.
2018-11-29 18:42:20 +01:00
Patrick Marchand 5fe9762c53 Inverse userdel(1) calls in scripts/web-add.sh
When a user has the same name as his primary group, userdel(1) tries
to remove it as well, but stops and prints an error message if that
group is being used by any other users as their primary group. By
deleting the www user first, the group is properly deleted. This
means we can get rid of the subsequent call to groupdel(1).

Tested by adding / removing a vhost on my testing vm.
2018-11-29 18:35:17 +01:00
Patrick Marchand 547235ea7e Audited scripts/stats.sh
Shellcheck pass and code cleanup.

Set stricter error handling with sh options.

Removes the for loop and cat(1) in favor of directly calling the
file with cut(1) and piping the output to a while read loop. Read
https://github.com/koalaman/shellcheck/wiki/SC2002 for more info.

Adds proper variable globbing.

Removes the large block of commented code, if this turns out to be
necessary, we can add a condition check to the script instead of
uncommenting on a per case basis.
2018-11-29 17:25:13 +01:00
Patrick Marchand cade94a7bc Merge of README.md and forge wiki 2018-11-26 17:35:46 +01:00
Patrick Marchand b693075f39 Adds command to fix vhost linking problems in web-add.sh
Some people forget to use the --follow-symlinks flag with sed(1),
thus not carrying changes over to /etc/apache2/sites-available.

This new command makes sure all vhosts in /etc/apache2/sites-enabled
are symlinks. It assumes that we always want to overwrite the file in
/etc/apache2/sites-available with the file in /etc/apache2/sites-enabled.
2018-11-22 20:15:06 +01:00
Patrick Marchand d64cfa4e8b Fix problems with web-add.sh add-alias
All uses of the VHOST_PATH variable in the code append a slash to
it, so it is easier to remove the trailing slash in it's instantiation.

Also simplifies the sed(1) invocation.
2018-11-22 20:14:05 +01:00
Patrick Marchand a06f31e80a Merge branch 'shellcheck-ftpadmin' of evolix/evoadmin-web into master 2018-11-13 15:37:21 +01:00
Patrick Marchand 393851d4c6 Removed unecessary argument in ftpadmin.php delete
It caused errors because it wasnt set in some cases, but was never
even checked by the invoked shell script.
2018-11-09 17:50:25 -05:00
Patrick Marchand d3be332ba4 Shellcheck on delete_account in ftpadmin
Removed useless echo and added variable quoting.
2018-11-09 17:48:35 -05:00
Patrick Marchand 58642ec0ac Made ftpadmin more usable from the commandline
Adds more portable bash invocation.

Adds more severe bash evaluation.

Added h flag and made improper use print the usage function.

Added checks that make sure the parameters are okay.

Proper variable quoting, tests and $() use.
2018-11-09 17:45:01 -05:00
Patrick Marchand 2ab5a60906 Shellcheck pass on edit_password in ftpadmin
Removed useless echo and used proper variable quoting.
2018-11-09 17:42:47 -05:00
Patrick Marchand 66c2c8ab35 Shellcheck pass on add_account in ftpadmin
Simple variable quoting and more modern shell constructs.
2018-11-09 17:41:32 -05:00
Patrick Marchand e97ddd8be0 Simplification of list_account_by_UID in ftpadmin
Setting / unsetting IFS variables can be removed by setting it only
in the loop context.

The for cat can be replaced by a simpler while read loop.

Proper variable quoting was added.

Changed the way modif was optionally passed, this removes the
extraneous ':' at the end.

echo(1) the lines as we go instead of building an array, this removes
the possibility of sub-shell screwups.
2018-11-09 17:33:44 -05:00
Patrick Marchand e3a50177c8 Cleanup get_user_login_by_UID() in ftpadmin.sh
Adds proper variable quoting
2018-11-07 17:27:03 -05:00
Patrick Marchand 1e82272487 Clean log_msg() in ftpadmin.sh
Made the code a bit cleaner and added proper variable quoting.
2018-11-07 17:25:12 -05:00
Benoît S. 872f1532d5 Merge branch 'shellcheck-web-add' of evolix/evoadmin-web into master 2018-11-07 15:44:47 +01:00
Patrick Marchand 08ef18bc2d Use ${var:+...} instead of [-n ] and "$@" instead of "$*"
Fixes issue uncovered by proper use of double quotes.
2018-10-25 11:37:21 -04:00
Patrick Marchand 540b7f7278 Use ${var:+...} instead of [-n ] and "$@" instead of "$*"
Fixes issue uncovered by proper use of double quotes
2018-10-17 16:30:58 -04:00
Patrick Marchand e596e3d520 Use $(..) instead of legacy ..
https://github.com/koalaman/shellcheck/wiki/SC2006
modified:   scripts/web-add.sh
2018-10-16 14:51:50 -04:00
Patrick Marchand 97bad77040 Add -r to read
I'm less certain about the necessity of this, but if it doesnt cause
problems, I dont see why not.
https://github.com/koalaman/shellcheck/wiki/SC2162
modified:   scripts/web-add.sh
2018-10-16 14:49:43 -04:00
Patrick Marchand 05c9525d7e $/${} is unnecessary on arithmetic variables
https://github.com/koalaman/shellcheck/wiki/SC2004
modified:   scripts/web-add.sh
2018-10-16 14:46:16 -04:00
Patrick Marchand f4fae90eb1 Useless cat
https://github.com/koalaman/shellcheck/wiki/SC2002
modified:   scripts/web-add.sh
2018-10-16 14:43:26 -04:00
Patrick Marchand 5d2d8be5ad Prefer explicit escaping
https://github.com/koalaman/shellcheck/wiki/SC1117
modified:   scripts/web-add.sh
2018-10-16 14:39:23 -04:00
Patrick Marchand 2861d90119 Fixes optional group creation
The optional group creation flag in scripts/web-add.sh was never used.
2018-10-16 14:35:23 -04:00
Patrick Marchand 4aa0332639 Use "$@" (with quotes) to prevent whitespace problems
https://github.com/koalaman/shellcheck/wiki/SC2048
modified:   web-add.sh
2018-10-16 14:32:47 -04:00
Patrick Marchand 866f20ef47 Adds double quoting to prevent shell globing
modified:   web-add.sh
2018-10-16 14:28:27 -04:00
Patrick Marchand 3e422bc2bf Adds shellcheck source comments
This will allow someone to use shellcheck(1) to automatically check
any referenced code using `shellcheck -x scripts/web-add.sh`
2018-10-16 14:10:02 -04:00
Benoît S. 2125523cd8 Update suite utilisation en prod 2018-09-06 14:53:41 +02:00
Benoît S. 45ce021a5c For Stretch the awstats Include has changed 2018-06-13 15:22:07 +02:00
Victor LABORIE 353d41a8a6 web_add with php_versions need global var "conf" 2018-05-31 16:38:34 +02:00
Jérémy Lecour 25d9f7e7d4 web-add: use group "evolinux-ssh 2018-04-20 11:20:06 +02:00
Jérémy Lecour 637e72743a web-add.sh: whitespaces 2018-04-19 23:02:15 +02:00
Jérémy Lecour 99ee37b408 web-add.sh: use AllowGroups or AllowUsers as needed 2018-04-19 23:02:15 +02:00
Victor LABORIE 9ff6846c36 Fix indentation for .my.cnf 2017-10-17 10:44:58 +02:00
Ludovic Poujol 580ff1307e Add robots.txt 2017-10-16 11:53:45 +02:00
Gregory Colpart 00e15b32d7 add default_charset exemple in vhost template 2017-09-12 20:15:48 +02:00
Gregory Colpart aaf2316fa5 bye bye php.log 2017-09-08 03:53:53 +02:00
Gregory Colpart 75c341fed9 bye bye pam_auth() 2017-09-08 03:53:42 +02:00
Romain Dessort 882c464405 Fix od_del() when containers are not used 2017-09-07 11:29:31 -04:00
Gregory Colpart 7e804984d1 add gitgnore for local conf 2017-09-01 03:37:39 +02:00
Gregory Colpart 1a2c47986c Put auth hashs in conf file 2017-09-01 03:35:16 +02:00
Gregory Colpart ea4d220a59 Fix old script name after recent features merge 2017-09-01 03:27:24 +02:00
Gregory Colpart 53f280096a Fix in sed replacements 2017-09-01 03:21:28 +02:00
Romain Dessort 5a5063e4cb Add comment for php_versions 2017-08-25 17:22:53 -04:00
Romain Dessort 5eb619a579 Fix FPM socket path + quota 2017-08-25 17:22:26 -04:00
Romain Dessort 4a28ee1f53 Fix op_del() function for containers 2017-08-25 16:58:04 -04:00
Romain Dessort a5ceadd1d0 Fix FPM socket path 2017-08-25 16:57:38 -04:00
Romain Dessort c166975d46 Use same UID/GID in containers 2017-08-25 16:56:30 -04:00
Romain Dessort 0968dbc797 phpversion and quota options should be optional 2017-08-25 08:48:09 -04:00
Romain Dessort 6b63c02f77 Fix bug related to Apache/Nginx merge 2017-08-25 08:47:42 -04:00
Romain Dessort d27490a49f Add dbadmin option in configuration 2017-08-24 13:06:53 -04:00
Benoît S. 1bee32dd65 Merge branch 'web-add-support-nginx-and-apache' 2017-08-23 14:22:42 +02:00
Benoît S. 29bbfab45a Merge web-add-nginx features to web-add
This add support for apache and nginx in the same script.
2017-08-23 14:19:48 +02:00
Romain Dessort 623f281628 Add new features in web-add.sh script (related to 483482a):
- Unix quota management
  - support for multiple versions of PHP running in LXC containers with FPM
  - don't include MySQL information in summary email if no database is created
  - possibility to set custom MySQL connection parameters
  - fix op_listvhost() function since config file now ended with .conf
    and include useful additional informations (PHP version, used disk
    size, vhost enabled).
  - add scripts to manage/report MySQL databases and users (used by
    evoadmin dbadmin.php page)
2017-08-22 17:29:51 -04:00
Romain Dessort 483482ab59 Add new features:
- Unix quota management
  - Apache ServerAlias management
  - support for multiple versions of PHP
  - MySQL databases management (new page dbadmin)
2017-08-22 12:50:42 -04:00
Gregory Colpart ee8b8a6437 oops, forget to remove debug code :( 2017-08-20 05:19:56 +02:00
Gregory Colpart 4dca34f979 Fix bug with add ServerAlias ! 2017-08-20 05:17:57 +02:00
Gregory Colpart d7bfd75b76 fix serveralias display 2017-08-20 05:10:36 +02:00
Gregory Colpart 7ed492470c indent + fix typo 2017-08-20 05:05:04 +02:00
Gregory Colpart c5b6db810f introduce bindadmin var to know if we need deal with DNS stuff 2017-08-20 04:41:44 +02:00
Gregory Colpart 2947fa2c87 NO CODE IN THIS COMMIT. ONLY :retab replacement aka remove-all-tabs-from-code commit 2017-08-20 04:31:00 +02:00
Gregory Colpart d16fe6fd70 set ftpadmin to FALSE by default. and fix typo. 2017-08-20 04:30:30 +02:00
Gregory Colpart 4dc9c63cbc use right session name 2017-08-20 04:11:53 +02:00
Gregory Colpart 6f3a6ccadd Remove PAM bullshit auth for a simple/stupid sha256 static auth 2017-08-20 04:08:06 +02:00
Victor Laborie a5fe856592 Add web-add script for Nginx/PHP-FPM 2017-08-15 11:20:24 -04:00
60 changed files with 5437 additions and 1368 deletions

3
.gitignore vendored Normal file
View file

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

66
CHANGELOG.md Normal file
View 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

View file

@ -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
View file

@ -1,281 +1,620 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
GNU AFFERO GENERAL PUBLIC LICENSE
Version 3, 19 November 2007
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Lesser General Public License instead.) You can apply it to
your programs, too.
The GNU Affero General Public License is a free, copyleft license for
software and other kinds of works, specifically designed to ensure
cooperation with the community in the case of network server software.
The licenses for most software and other practical works are designed
to take away your freedom to share and change the works. By contrast,
our General Public Licenses are intended to guarantee your freedom to
share and change all versions of a program--to make sure it remains free
software for all its users.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
them if you wish), that you receive source code or can get it if you
want it, that you can change the software or use pieces of it in new
free programs, and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
Developers that use our General Public Licenses protect your rights
with two steps: (1) assert copyright on the software, and (2) offer
you this License which gives you legal permission to copy, distribute
and/or modify the software.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
A secondary benefit of defending all users' freedom is that
improvements made in alternate versions of the program, if they
receive widespread use, become available for other developers to
incorporate. Many developers of free software are heartened and
encouraged by the resulting cooperation. However, in the case of
software used on network servers, this result may fail to come about.
The GNU General Public License permits making a modified version and
letting the public access it on a server without ever releasing its
source code to the public.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
The GNU Affero General Public License is designed specifically to
ensure that, in such cases, the modified source code becomes available
to the community. It requires the operator of a network server to
provide the source code of the modified version running there to the
users of that server. Therefore, public use of a modified version, on
a publicly accessible server, gives the public access to the source
code of the modified version.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
An older license, called the Affero General Public License and
published by Affero, was designed to accomplish similar goals. This is
a different license, not a version of the Affero GPL, but Affero has
released a new version of the Affero GPL which permits relicensing under
this license.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
TERMS AND CONDITIONS
0. This License applies to any program or other work which contains
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".
0. Definitions.
Activities other than copying, distribution and modification are not
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.
"This License" refers to version 3 of the GNU Affero General Public License.
1. You may copy and distribute 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 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.
"Copyright" also means copyright-like laws that apply to other kinds of
works, such as semiconductor masks.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
"The Program" refers to any copyrightable work licensed under this
License. Each licensee is addressed as "you". "Licensees" and
"recipients" may be individuals or organizations.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
To "modify" a work means to copy from or adapt all or part of the work
in a fashion requiring copyright permission, other than the making of an
exact copy. The resulting work is called a "modified version" of the
earlier work or a work "based on" the earlier work.
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
A "covered work" means either the unmodified Program or a work based
on the Program.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
To "propagate" a work means to do anything with it that, without
permission, would make you directly or secondarily liable for
infringement under applicable copyright law, except executing it on a
computer or modifying a private copy. Propagation includes copying,
distribution (with or without modification), making available to the
public, and in some countries other activities as well.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
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.)
To "convey" a work means any kind of propagation that enables other
parties to make or receive copies. Mere interaction with a user through
a computer network, with no transfer of a copy, is not conveying.
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
An interactive user interface displays "Appropriate Legal Notices"
to the extent that it includes a convenient and prominently visible
feature that (1) displays an appropriate copyright notice, and (2)
tells the user that there is no warranty for the work (except to the
extent that warranties are provided), that licensees may convey the
work under this License, and how to view a copy of this License. If
the interface presents a list of user commands or options, such as a
menu, a prominent item in the list meets this criterion.
Thus, it is not the intent of this section to claim rights or contest
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.
1. Source Code.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
The "source code" for a work means the preferred form of the work
for making modifications to it. "Object code" means any non-source
form of a work.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
A "Standard Interface" means an interface that either is an official
standard defined by a recognized standards body, or, in the case of
interfaces specified for a particular programming language, one that
is widely used among developers working in that language.
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
The "System Libraries" of an executable work include anything, other
than the work as a whole, that (a) is included in the normal form of
packaging a Major Component, but which is not part of that Major
Component, and (b) serves only to enable use of the work with that
Major Component, or to implement a Standard Interface for which an
implementation is available to the public in source code form. A
"Major Component", in this context, means a major essential component
(kernel, window system, and so on) of the specific operating system
(if any) on which the executable work runs, or a compiler used to
produce the work, or an object code interpreter used to run it.
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
The "Corresponding Source" for a work in object code form means all
the source code needed to generate, install, and (for an executable
work) run the object code and to modify the work, including scripts to
control those activities. However, it does not include the work's
System Libraries, or general-purpose tools or generally available free
programs which are used unmodified in performing those activities but
which are not part of the work. For example, Corresponding Source
includes interface definition files associated with source files for
the work, and the source code for shared libraries and dynamically
linked subprograms that the work is specifically designed to require,
such as by intimate data communication or control flow between those
subprograms and other parts of the work.
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The Corresponding Source need not include anything that users
can regenerate automatically from other parts of the Corresponding
Source.
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
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.
The Corresponding Source for a work in source code form is that
same work.
If distribution of executable or object code is made by offering
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.
2. Basic Permissions.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
All rights granted under this License are granted for the term of
copyright on the Program, and are irrevocable provided the stated
conditions are met. This License explicitly affirms your unlimited
permission to run the unmodified Program. The output from running a
covered work is covered by this License only if the output, given its
content, constitutes a covered work. This License acknowledges your
rights of fair use or other equivalent, as provided by copyright law.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
You may make, run and propagate covered works that you do not
convey, without conditions so long as your license otherwise remains
in force. You may convey covered works to others for the sole purpose
of having them make modifications exclusively for you, or provide you
with facilities for running those works, provided that you comply with
the terms of this License in conveying all material for which you do
not control copyright. Those thus making or running the covered works
for you must do so exclusively on your behalf, under your direction
and control, on terms that prohibit them from making any copies of
your copyrighted material outside their relationship with you.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
Conveying under any other circumstances is permitted solely under
the conditions stated below. Sublicensing is not allowed; section 10
makes it unnecessary.
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
No covered work shall be deemed part of an effective technological
measure under any applicable law fulfilling obligations under article
11 of the WIPO copyright treaty adopted on 20 December 1996, or
similar laws prohibiting or restricting circumvention of such
measures.
When you convey a covered work, you waive any legal power to forbid
circumvention of technological measures to the extent such circumvention
is effected by exercising rights under this License with respect to
the covered work, and you disclaim any intention to limit operation or
modification of the work as a means of enforcing, against the work's
users, your or third parties' legal rights to forbid circumvention of
technological measures.
4. Conveying Verbatim Copies.
You may convey verbatim copies of the Program's source code as you
receive it, in any medium, provided that you conspicuously and
appropriately publish on each copy an appropriate copyright notice;
keep intact all notices stating that this License and any
non-permissive terms added in accord with section 7 apply to the code;
keep intact all notices of the absence of any warranty; and give all
recipients a copy of this License along with the Program.
You may charge any price or no price for each copy that you convey,
and you may offer support or warranty protection for a fee.
5. Conveying Modified Source Versions.
You may convey a work based on the Program, or the modifications to
produce it from the Program, in the form of source code under the
terms of section 4, provided that you also meet all of these conditions:
a) The work must carry prominent notices stating that you modified
it, and giving a relevant date.
b) The work must carry prominent notices stating that it is
released under this License and any conditions added under section
7. This requirement modifies the requirement in section 4 to
"keep intact all notices".
c) You must license the entire work, as a whole, under this
License to anyone who comes into possession of a copy. This
License will therefore apply, along with any applicable section 7
additional terms, to the whole of the work, and all its parts,
regardless of how they are packaged. This License gives no
permission to license the work in any other way, but it does not
invalidate such permission if you have separately received it.
d) If the work has interactive user interfaces, each must display
Appropriate Legal Notices; however, if the Program has interactive
interfaces that do not display Appropriate Legal Notices, your
work need not make them do so.
A compilation of a covered work with other separate and independent
works, which are not by their nature extensions of the covered work,
and which are not combined with it such as to form a larger program,
in or on a volume of a storage or distribution medium, is called an
"aggregate" if the compilation and its resulting copyright are not
used to limit the access or legal rights of the compilation's users
beyond what the individual works permit. Inclusion of a covered work
in an aggregate does not cause this License to apply to the other
parts of the aggregate.
6. Conveying Non-Source Forms.
You may convey a covered work in object code form under the terms
of sections 4 and 5, provided that you also convey the
machine-readable Corresponding Source under the terms of this License,
in one of these ways:
a) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by the
Corresponding Source fixed on a durable physical medium
customarily used for software interchange.
b) Convey the object code in, or embodied in, a physical product
(including a physical distribution medium), accompanied by a
written offer, valid for at least three years and valid for as
long as you offer spare parts or customer support for that product
model, to give anyone who possesses the object code either (1) a
copy of the Corresponding Source for all the software in the
product that is covered by this License, on a durable physical
medium customarily used for software interchange, for a price no
more than your reasonable cost of physically performing this
conveying of source, or (2) access to copy the
Corresponding Source from a network server at no charge.
c) Convey individual copies of the object code with a copy of the
written offer to provide the Corresponding Source. This
alternative is allowed only occasionally and noncommercially, and
only if you received the object code with such an offer, in accord
with subsection 6b.
d) Convey the object code by offering access from a designated
place (gratis or for a charge), and offer equivalent access to the
Corresponding Source in the same way through the same place at no
further charge. You need not require recipients to copy the
Corresponding Source along with the object code. If the place to
copy the object code is a network server, the Corresponding Source
may be on a different server (operated by you or a third party)
that supports equivalent copying facilities, provided you maintain
clear directions next to the object code saying where to find the
Corresponding Source. Regardless of what server hosts the
Corresponding Source, you remain obligated to ensure that it is
available for as long as needed to satisfy these requirements.
e) Convey the object code using peer-to-peer transmission, provided
you inform other peers where the object code and Corresponding
Source of the work are being offered to the general public at no
charge under subsection 6d.
A separable portion of the object code, whose source code is excluded
from the Corresponding Source as a System Library, need not be
included in conveying the object code work.
A "User Product" is either (1) a "consumer product", which means any
tangible personal property which is normally used for personal, family,
or household purposes, or (2) anything designed or sold for incorporation
into a dwelling. In determining whether a product is a consumer product,
doubtful cases shall be resolved in favor of coverage. For a particular
product received by a particular user, "normally used" refers to a
typical or common use of that class of product, regardless of the status
of the particular user or of the way in which the particular user
actually uses, or expects or is expected to use, the product. A product
is a consumer product regardless of whether the product has substantial
commercial, industrial or non-consumer uses, unless such uses represent
the only significant mode of use of the product.
"Installation Information" for a User Product means any methods,
procedures, authorization keys, or other information required to install
and execute modified versions of a covered work in that User Product from
a modified version of its Corresponding Source. The information must
suffice to ensure that the continued functioning of the modified object
code is in no case prevented or interfered with solely because
modification has been made.
If you convey an object code work under this section in, or with, or
specifically for use in, a User Product, and the conveying occurs as
part of a transaction in which the right of possession and use of the
User Product is transferred to the recipient in perpetuity or for a
fixed term (regardless of how the transaction is characterized), the
Corresponding Source conveyed under this section must be accompanied
by the Installation Information. But this requirement does not apply
if neither you nor any third party retains the ability to install
modified object code on the User Product (for example, the work has
been installed in ROM).
The requirement to provide Installation Information does not include a
requirement to continue to provide support service, warranty, or updates
for a work that has been modified or installed by the recipient, or for
the User Product in which it has been modified or installed. Access to a
network may be denied when the modification itself materially and
adversely affects the operation of the network or violates the rules and
protocols for communication across the network.
Corresponding Source conveyed, and Installation Information provided,
in accord with this section must be in a format that is publicly
documented (and with an implementation available to the public in
source code form), and must require no special password or key for
unpacking, reading or copying.
7. Additional Terms.
"Additional permissions" are terms that supplement the terms of this
License by making exceptions from one or more of its conditions.
Additional permissions that are applicable to the entire Program shall
be treated as though they were included in this License, to the extent
that they are valid under applicable law. If additional permissions
apply only to part of the Program, that part may be used separately
under those permissions, but the entire Program remains governed by
this License without regard to the additional permissions.
When you convey a copy of a covered work, you may at your option
remove any additional permissions from that copy, or from any part of
it. (Additional permissions may be written to require their own
removal in certain cases when you modify the work.) You may place
additional permissions on material, added by you to a covered work,
for which you have or can give appropriate copyright permission.
Notwithstanding any other provision of this License, for material you
add to a covered work, you may (if authorized by the copyright holders of
that material) supplement the terms of this License with terms:
a) Disclaiming warranty or limiting liability differently from the
terms of sections 15 and 16 of this License; or
b) Requiring preservation of specified reasonable legal notices or
author attributions in that material or in the Appropriate Legal
Notices displayed by works containing it; or
c) Prohibiting misrepresentation of the origin of that material, or
requiring that modified versions of such material be marked in
reasonable ways as different from the original version; or
d) Limiting the use for publicity purposes of names of licensors or
authors of the material; or
e) Declining to grant rights under trademark law for use of some
trade names, trademarks, or service marks; or
f) Requiring indemnification of licensors and authors of that
material by anyone who conveys the material (or modified versions of
it) with contractual assumptions of liability to the recipient, for
any liability that these contractual assumptions directly impose on
those licensors and authors.
All other non-permissive additional terms are considered "further
restrictions" within the meaning of section 10. If the Program as you
received it, or any part of it, contains a notice stating that it is
governed by this License along with a term that is a further
restriction, you may remove that term. If a license document contains
a further restriction but permits relicensing or conveying under this
License, you may add to a covered work material governed by the terms
of that license document, provided that the further restriction does
not survive such relicensing or conveying.
If you add terms to a covered work in accord with this section, you
must place, in the relevant source files, a statement of the
additional terms that apply to those files, or a notice indicating
where to find the applicable terms.
Additional terms, permissive or non-permissive, may be stated in the
form of a separately written license, or stated as exceptions;
the above requirements apply either way.
8. Termination.
You may not propagate or modify a covered work except as expressly
provided under this License. Any attempt otherwise to propagate or
modify it is void, and will automatically terminate your rights under
this License (including any patent licenses granted under the third
paragraph of section 11).
However, if you cease all violation of this License, then your
license from a particular copyright holder is reinstated (a)
provisionally, unless and until the copyright holder explicitly and
finally terminates your license, and (b) permanently, if the copyright
holder fails to notify you of the violation by some reasonable means
prior to 60 days after the cessation.
Moreover, your license from a particular copyright holder is
reinstated permanently if the copyright holder notifies you of the
violation by some reasonable means, this is the first time you have
received notice of violation of this License (for any work) from that
copyright holder, and you cure the violation prior to 30 days after
your receipt of the notice.
Termination of your rights under this section does not terminate the
licenses of parties who have received copies or rights from you under
this License. If your rights have been terminated and not permanently
reinstated, you do not qualify to receive new licenses for the same
material under section 10.
9. Acceptance Not Required for Having Copies.
You are not required to accept this License in order to receive or
run a copy of the Program. Ancillary propagation of a covered work
occurring solely as a consequence of using peer-to-peer transmission
to receive a copy likewise does not require acceptance. However,
nothing other than this License grants you permission to propagate or
modify any covered work. These actions infringe copyright if you do
not accept this License. Therefore, by modifying or propagating a
covered work, you indicate your acceptance of this License to do so.
10. Automatic Licensing of Downstream Recipients.
Each time you convey a covered work, the recipient automatically
receives a license from the original licensors, to run, modify and
propagate that work, subject to this License. You are not responsible
for enforcing compliance by third parties with this License.
An "entity transaction" is a transaction transferring control of an
organization, or substantially all assets of one, or subdividing an
organization, or merging organizations. If propagation of a covered
work results from an entity transaction, each party to that
transaction who receives a copy of the work also receives whatever
licenses to the work the party's predecessor in interest had or could
give under the previous paragraph, plus a right to possession of the
Corresponding Source of the work from the predecessor in interest, if
the predecessor has it or can get it with reasonable efforts.
You may not impose any further restrictions on the exercise of the
rights granted or affirmed under this License. For example, you may
not impose a license fee, royalty, or other charge for exercise of
rights granted under this License, and you may not initiate litigation
(including a cross-claim or counterclaim in a lawsuit) alleging that
any patent claim is infringed by making, using, selling, offering for
sale, or importing the Program or any portion of it.
11. Patents.
A "contributor" is a copyright holder who authorizes use under this
License of the Program or a work on which the Program is based. The
work thus licensed is called the contributor's "contributor version".
A contributor's "essential patent claims" are all patent claims
owned or controlled by the contributor, whether already acquired or
hereafter acquired, that would be infringed by some manner, permitted
by this License, of making, using, or selling its contributor version,
but do not include claims that would be infringed only as a
consequence of further modification of the contributor version. For
purposes of this definition, "control" includes the right to grant
patent sublicenses in a manner consistent with the requirements of
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
Each contributor grants you a non-exclusive, worldwide, royalty-free
patent license under the contributor's essential patent claims, to
make, use, sell, offer for sale, import and otherwise run, modify and
propagate the contents of its contributor version.
In the following three paragraphs, a "patent license" is any express
agreement or commitment, however denominated, not to enforce a patent
(such as an express permission to practice a patent or covenant not to
sue for patent infringement). To "grant" such a patent license to a
party means to make such an agreement or commitment not to enforce a
patent against the party.
If you convey a covered work, knowingly relying on a patent license,
and the Corresponding Source of the work is not available for anyone
to copy, free of charge and under the terms of this License, through a
publicly available network server or other readily accessible means,
then you must either (1) cause the Corresponding Source to be so
available, or (2) arrange to deprive yourself of the benefit of the
patent license for this particular work, or (3) arrange, in a manner
consistent with the requirements of this License, to extend the patent
license to downstream recipients. "Knowingly relying" means you have
actual knowledge that, but for the patent license, your conveying the
covered work in a country, or your recipient's use of the covered work
in a country, would infringe one or more identifiable patents in that
country that you have reason to believe are valid.
If, pursuant to or in connection with a single transaction or
arrangement, you convey, or propagate by procuring conveyance of, a
covered work, and grant a patent license to some of the parties
receiving the covered work authorizing them to use, propagate, modify
or convey a specific copy of the covered work, then the patent license
you grant is automatically extended to all recipients of the covered
work and works based on it.
A patent license is "discriminatory" if it does not include within
the scope of its coverage, prohibits the exercise of, or is
conditioned on the non-exercise of one or more of the rights that are
specifically granted under this License. You may not convey a covered
work if you are a party to an arrangement with a third party that is
in the business of distributing software, under which you make payment
to the third party based on the extent of your activity of conveying
the work, and under which the third party grants, to any of the
parties who would receive the covered work from you, a discriminatory
patent license (a) in connection with copies of the covered work
conveyed by you (or copies made from those copies), or (b) primarily
for and in connection with specific products or compilations that
contain the covered work, unless you entered into that arrangement,
or that patent license was granted, prior to 28 March 2007.
Nothing in this License shall be construed as excluding or limiting
any implied license or other defenses to infringement that may
otherwise be available to you under applicable patent law.
12. No Surrender of Others' Freedom.
If conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
excuse you from the conditions of this License. If you cannot convey a
covered work so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you may
not convey it at all. For example, if you agree to terms that obligate you
to collect a royalty for further conveying from those to whom you convey
the Program, the only way you could satisfy both those terms and this
License would be to refrain entirely from conveying the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
13. Remote Network Interaction; Use with the GNU General Public License.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
Notwithstanding any other provision of this License, if you modify the
Program, your modified version must prominently offer all users
interacting with it remotely through a computer network (if your version
supports such interaction) an opportunity to receive the Corresponding
Source of your version by providing access to the Corresponding Source
from a network server at no charge, through some standard or customary
means of facilitating copying of software. This Corresponding Source
shall include the Corresponding Source for any work covered by version 3
of the GNU General Public License that is incorporated pursuant to the
following paragraph.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
Notwithstanding any other provision of this License, you have
permission to link or combine any covered work with a work licensed
under version 3 of the GNU 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
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.
14. Revised Versions of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
The Free Software Foundation may publish revised and/or new versions of
the GNU Affero General Public License from time to time. Such new versions
will be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
Each version is given a distinguishing version number. If the
Program specifies that a certain numbered version of the GNU Affero General
Public License "or any later version" applies to it, you have the
option of following the terms and conditions either of that numbered
version or of any later version published by the Free Software
Foundation. If the Program does not specify a version number of the
GNU Affero General Public License, you may choose any version ever published
by the Free Software Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
If the Program specifies that a proxy can decide which future
versions of the GNU Affero General Public License can be used, that proxy's
public statement of acceptance of a version permanently authorizes you
to choose that version for the Program.
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
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.
15. Disclaimer of Warranty.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE 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.
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. Limitation of Liability.
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
SUCH DAMAGES.
17. Interpretation of Sections 15 and 16.
If the disclaimer of warranty and limitation of liability provided
above cannot be given local legal effect according to their terms,
reviewing courts shall apply local law that most closely approximates
an absolute waiver of all civil liability in connection with the
Program, unless a warranty or assumption of liability accompanies a
copy of the Program in return for a fee.
END OF TERMS AND CONDITIONS
@ -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 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.
Copyright (C) 2013 Benoît.S
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU 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
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
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
when it starts in an interactive mode:
If your software can interact with users remotely through a computer
network, you should also make sure that it provides a way for users to
get its source. For example, if your program is a web application, its
interface could display a "Source" link that leads users to an archive
of the code. There are many ways you could offer source, and different
solutions will be better for different programs; see section 13 for the
specific requirements.
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, 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.
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU AGPL, see
<https://www.gnu.org/licenses/>.

View file

@ -1,3 +1,48 @@
evoadmin-web
============
Panel d'administration de serveur web.
# Evoadmin-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
View 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
View file

@ -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
View 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

View file

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

View file

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

View file

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

View file

@ -8,26 +8,35 @@
* $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>
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @version 1.0
*/
// Email pour les notifications
$oriconf['admin']['mail'] = 'admin@example.com';
$oriconf['techmail'] = 'jdoe@example.com';
$oriconf['debug'] = FALSE;
$oriconf['debug'] = false;
$oriconf['superadmin'] = array('superadmin');
$oriconf['script_path'] = '/usr/share/scripts/evoadmin';
$oriconf['cluster'] = FALSE;
$oriconf['cluster'] = false;
$oriconf['servers'] = array('servers');
$oriconf['cache'] = '/home/evoadmin/www/cache.sqlite';
$localconf['known_host'] = '/home/evoadmin/www/known_host';
$oriconf['ftpadmin'] = TRUE;
$oriconf['known_host'] = '/home/evoadmin/www/known_host';
$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;
$oriconf['noreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com');
$oriconf['postponedreplication'] = array('srv00.example.com', 'srv01.example.com', 'srv02.example.com');
$oriconf['immediatereplication'] = array('srv00.example.com', 'srv01.example.com');
$oriconf['postponedreplication_mode'] = array('1 fois/jour', '3 fois/jour', '1 fois/jour');
// Generate password hashes : mkpasswd --method=sha-512 (cli) or with PHP's password_hash()
$oriconf['logins'] = array();
//$oriconf['logins']['foo'] = '$6$X0jqa/ausLSBkj4m$dLMMcPGVxak.aDPo4V/GJLm2d8vU8/QA5LbGTuqXCdxSNYU0kRKBgDl16GAyp0GqXXZ5wwDEJKQ1npgFwiuV81';
//$oriconf['logins']['bar'] = '$6$Q6233S6mlWAF6p.j$LtzwG02YucozwqjAgSpeldh24Mnz7lBuVSbOQYbKKh9FiUx3tMVl6kJZkmrNdPqeadFXKAYXrqn.gy8KposF5.';

View file

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

View file

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

View file

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

View file

@ -21,6 +21,12 @@ function switch_disabled(name) {
}
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() {
switch_disabled('password');
}

View file

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

2
htdocs/robots.txt Normal file
View file

@ -0,0 +1,2 @@
User-agent: *
Disallow: /

View file

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

View file

@ -1,57 +1,53 @@
<?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 Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @author Evolix <info@evolix.fr>
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
* @author Sebastien Palma <spalma@evolix.fr>
* @author and others.
* @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)) {
$login=0;
$username=$_POST['login'];
$password=$_POST['passw'];
} elseif (isset($conf['logins'][$input_username]) && strlen($conf['logins'][$input_username]) == 64 && hash("sha256",$input_password) === $conf['logins'][$input_username]) {
// Compatibility mode for previous installs (sha256)
$_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']);
} else {
$_SESSION['auth'] = false;
$_SESSION['user'] = '';
$_SESSION['error'] = true;
}
$login = pam_auth($username, $password);
if ($login==1) {
$_SESSION['auth']=1;
$_SESSION['user']=$username;
$_SESSION['error']='';
$user = posix_getpwnam($username);
// On nettoie le nom complet
$gecos = explode(',',$user['gecos']);
$user['gecos'] = $gecos[0];
$_SESSION['user_id'] = $user['uid'];
$_SESSION['user_gid'] = $user['gid'];
$_SESSION['user_name'] = $user['gecos'];
} else {
$_SESSION['auth']=0;
$_SESSION['user']='';
$_SESSION['error']=1;
}
http_redirect('/');
http_redirect('/');
} else {
if(!empty($_SESSION['error'])) {
$error=$_SESSION['error'];
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/auth.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
if (!empty($_SESSION['error'])) {
$error = $_SESSION['error'];
unset($_SESSION['error']);
}
include_once EVOADMIN_BASE . '../tpl/header.tpl.php';
include_once EVOADMIN_BASE . '../tpl/auth.tpl.php';
include_once EVOADMIN_BASE . '../tpl/footer.tpl.php';
}
?>

View file

@ -1,5 +1,4 @@
<?php
/**
* file included in every PHP file
*
@ -27,7 +26,7 @@ function test_exist($file) {
}
function http_redirect($path) {
header('Location: http://'.$_SERVER['HTTP_HOST'].$path);
header('Location: '.$_SERVER['REQUEST_SCHEME'].'://'.$_SERVER['HTTP_HOST'].$path);
exit(0);
}
@ -87,6 +86,35 @@ function load_config_cluster($cluster) {
$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
*/
@ -107,7 +135,5 @@ if (!(ini_set('include_path', ini_get('include_path')))) {
require_once('../conf/config.php');
test_exist('../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);
}

45
inc/dbadmin.php Normal file
View 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';
?>

View file

@ -155,7 +155,7 @@ if ($action=="add") {
} 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;
@ -200,13 +200,13 @@ if ($action=="add") {
$size_total += $infos[3];
$table[$num_line]['size'] = formatBytes($infos[3]);
} else {
$table[$num_line]['size'] = 0;
$table[$num_line]['size'] = 0;
}
if ($infos[4]>0) {
$table[$num_line]['date'] = date("d/m/Y h:i:s", $infos[4]);
} else {
$table[$num_line]['date'] = "01/01/1970";
$table[$num_line]['date'] = "01/01/1970";
}
$num_line++;
@ -256,6 +256,7 @@ function get_owner_list() {
foreach(array_keys($usernames) as $cur) {
if(preg_match('/^www-/', $cur)) { continue; }
if($cur == "evoadmin") { continue; }
if(empty($usernames["www-$cur"])) { continue; }
$owner_list[] = $cur;
}

72
inc/webadmin-delete.php Normal file
View 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';
}
?>

View file

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

94
inc/webadmin-itk.php Normal file
View 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';
}
?>

View 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
View 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
View 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';
}
?>

View file

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

View file

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

View file

@ -17,13 +17,37 @@ function domain_add($name, $IP, $with_mxs, $gmail=false) {
$exec_cmd .= ' -m mail,10';
$exec_cmd .= ' -m backup.quai13.net.,20';
}
# mail('tech@evolix.fr', '[TAF] Ajouter '.$name.' sur quai13-backup', wordwrap('Ajouter le domaine '.$name.' à la directive relay_domains dans le fichier /etc/postfix/main.cf sur quai13-backup, pour mettre en place le MX secondaire du domaine.', 70));
}
$exec_cmd .= " -a $IP $name";
//echo $exec_cmd."\n";
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
View 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;
}
}

View file

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

View file

@ -43,7 +43,7 @@ add_mx () {
return 0
fi
if ! grep -q -E "^$mx_subdomain[ \t]+IN[ \t]+MX[ \t]+[[:digit:]]+[ \t]+$mx$" $zonefile; then
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."
@ -58,7 +58,7 @@ add_subdomain () {
zonefile="$BINDROOT/db.$domain"
if ! grep -q -E "^$subdomain[ \t]+IN[ \t]+(CNAME|A)[ \t]+" $zonefile; then
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."
@ -73,7 +73,7 @@ inc_and_reload () {
zonefile="$BINDROOT/db.$domain"
# Set the date for serial (only if greater than actual serial)
serial=$(grep -E '^[ \t]*[0-9]{10}[ \t]*; serial' $zonefile | sed "s/^[ \t]*\([0-9]\{10\}\)[ \t]*; serial/\1/")
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

View file

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

101
scripts/dbadmin.sh Executable file
View 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
View 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

View file

@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env bash
############################################################
# #
@ -13,6 +13,11 @@
# 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"
FTPLOG_PATH="/var/log/evolix-ftp.log"
@ -48,48 +53,38 @@ EOT
}
log_msg() {
curdate=`date +"%Y/%m/%d %H:%M:%S"`
echo "$curdate $1" >>$FTPLOG_PATH
curdate="$(date +"%Y/%m/%d %H:%M:%S")"
echo "$curdate $1" >> "$FTPLOG_PATH"
}
get_user_login_by_UID() {
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() {
uid=$1
uid=$1
# Remove # and empty lines
ftp_users=$(grep -v -E '^[[:blank:]]*(#.*)*$' "$VPASSWD_PATH")
account_list=''
oldIFS=IFS
IFS=$'\n'
for line in `cat $VPASSWD_PATH`
do
line_uid=`echo $line | cut -d":" -f3`
if [ ! "$uid" ] || [ "$line_uid" == "$uid" ]; then
username=`get_user_login_by_UID $line_uid`
account=`echo $line | cut -d":" -f1`
path=`echo $line | cut -d":" -f6`
if [ -r $path/.size ]; then
size=`cat $path/.size`
else
size=0
fi
#modif=`cat $path/.lastmodified`
# Passage en minuscule ?
#account=`echo $account | tr '[A-Z]' '[a-z]'`
#path=`echo $path | tr '[A-Z]' '[a-z]'`
account_list="${account_list}$username:$account:$path:$size:$modif\n"
fi
done
echo "$account_list"
IFS=$oldIFS
for line in $ftp_users; do
line_uid="$(echo "$line" | cut -d":" -f3)"
if [[ ! "$uid" ]] || [[ "$line_uid" == "$uid" ]]; then
username=$(get_user_login_by_UID "$line_uid")
account=$(echo "$line" | cut -d":" -f1)
path=$(echo "$line" | cut -d":" -f6)
size="inconnue"
# Check output of daily "du" cron job
# (set by ansible-roles/packweb-apache/tasks/main.yml)
if [ -r "$path/.size" ]; then
size=$(cat "$path/.size")
fi
#modif="$(cat $path/.lastmodified)"
echo "$username:$account:$path:$size${modif:+:$modif}"
fi
done
}
add_account() {
@ -99,18 +94,17 @@ add_account() {
passwd=$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
if [ ! -d "$path" ]; then
mkdir -p $path
chown $user_id:$user_gid $path
# Si le répertoire de travail du compte FTP n'existe pas, on le crée
if [[ ! -d "$path" ]]; then
mkdir -p "$path"
chown "$user_id":"$user_gid" "$path"
# fix by tmartin : s/655/755/
chmod 755 $path
setfacl -R -d -m 'o:rX' $path
chmod 755 "$path"
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)"
}
@ -118,7 +112,7 @@ edit_password() {
account_name=$1
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,48 +121,88 @@ delete_account() {
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"
}
while getopts a:u:n:f:p: opt; do
while getopts ha:u:n:f:p: opt; do
case "$opt" in
a)
in_action=$OPTARG
;;
in_action=$OPTARG
;;
u)
in_userid=$OPTARG
;;
in_userid=$OPTARG
;;
n)
in_accountname=$OPTARG
;;
in_accountname=$OPTARG
;;
f)
in_workpath=$OPTARG
;;
in_workpath=$OPTARG
;;
p)
in_password=$OPTARG
;;
in_password=$OPTARG
;;
h)
usage
exit 1
;;
*)
usage
exit 1
;;
esac
done
case "$in_action" in
case "${in_action-}" in
l)
account_list=`list_accounts_by_UID $in_userid`
echo -e -n $account_list
exit 1
;;
echo -e "$(list_accounts_by_UID "${in_userid-}")"
exit 1
;;
a)
echo -e -n `add_account $in_userid $in_accountname $in_workpath $in_password`
exit 1
;;
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
;;
m)
echo -e -n `edit_password $in_accountname $in_password`
exit 1;
;;
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;
;;
d)
echo -e -n `delete_account $in_accountname`
exit 1;
;;
if [[ -z "${in_accountname-}" ]]; then
echo "Account name not specified"
else
echo -e -n \
"$(delete_account "$in_accountname")"
fi
exit 1;
;;
*)
usage
exit 1
;;
esac

48
scripts/my-edit.sh Normal file
View 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

View file

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

View file

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

View file

@ -1,4 +1,4 @@
<VirtualHost *:80>
<VirtualHost *:80 *:443>
# FQDN principal
ServerName SERVERNAME
@ -7,6 +7,11 @@
# Repertoire principal
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
<Directory HOME_DIR/XXX/www/>
#Options +Indexes +SymLinksIfOwnerMatch
@ -61,8 +66,6 @@
#php_admin_value max_execution_time 60
#php_admin_value upload_max_filesize 8M
#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 error_log "HOME_DIR/XXX/log/php.log"
php_admin_value open_basedir "/usr/share/php:HOME_DIR/XXX:/tmp"
</VirtualHost>

41
scripts/vhost-nginx.tpl Normal file
View 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;
}
}

View file

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

649
scripts/web-add-nginx.sh Executable file
View 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 $*

View file

@ -1,10 +1,9 @@
#!/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
# $Id$
# Copyright (c) 2009-2017 Evolix - Tous droits reserves
#
# TODO
@ -15,27 +14,53 @@
set -e
VERSION="24.04"
HOME="/root"
CONTACT_MAIL="jdoe@example.org"
WWWBOUNCE_MAIL="jdoe@example.org"
SCRIPTS_PATH="/usr/share/scripts/evoadmin"
LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.local.sh"
PRE_LOCAL_SCRIPT="$SCRIPTS_PATH/web-add.pre-local.sh"
TPL_VHOST="$SCRIPTS_PATH/vhost"
TPL_AWSTATS="$SCRIPTS_PATH/awstats.XXX.conf"
TPL_MAIL="$SCRIPTS_PATH/web-mail.tpl"
VHOST_PATH="/etc/apache2/sites-enabled/"
SSH_GROUP="evolinux-ssh"
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
HOME_DIR="/home"
MYSQL_CREATE_DB_OPTS=""
MYSQL_OPTS=""
PHP_VERSIONS=()
# Utiliser ce fichier pour redefinir la valeur des variables ci-dessus
config_file="/etc/evolinux/web-add.conf"
# shellcheck source=/etc/evolinux/web-add.conf
[ -r $config_file ] && . $config_file
usage() {
cat <<EOT >&2
cat <<EOT >&2
Evoadmin web tooling - Version $VERSION
Usage: $0 COMMAND [ARG]
add [ [OPTIONS] LOGIN WWWDOMAIN ]
@ -70,18 +95,34 @@ add [ [OPTIONS] LOGIN WWWDOMAIN ]
-y
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)
Archive home directory.
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 Apache vhost for user LOGIN
check-vhosts -f
List suggested changes to vhosts, apply fixes with -f
add-alias VHOST ALIAS
Add a ServerAlias to an Apache vhost
@ -90,6 +131,53 @@ del-alias VHOST ALIAS
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
}
@ -97,8 +185,8 @@ EOT
# Affiche un message d'erreur de validation
#
in_error() {
msg=$1
cat >&2 <<EOT
msg=$1
cat >&2 <<EOT
***
Erreur : $msg
***
@ -106,346 +194,891 @@ EOT
}
gen_random_passwd() {
apg -c /dev/urandom -n1 -E oOlL10\&\\\/\"\'
apg -c /dev/urandom -MNCL -n1 -m18 -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
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}
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
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
dbname=$1
if mysql $MYSQL_OPTS -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
wwwdomain=$1
if [ -z "$wwwdomain" ]; then
in_error "Le nom de domaine est obligatoire"
return 1
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
}
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() {
msg=$1
echo "[OK] $msg"
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
# 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
if [ -f $PRE_LOCAL_SCRIPT ]; then
# shellcheck source=/usr/share/scripts/evoadmin/web-add.pre-local.sh
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
# 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
[ -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"
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")
# Create users inside all containers
for php_version in "${PHP_VERSIONS[@]}"; do
lxc-attach -n php"${php_version}" -- /usr/sbin/addgroup "$in_login" --gid "$gid" --force-badname >/dev/null
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
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
done
if grep -qE '^AllowUsers' /etc/ssh/sshd_config; then
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
else
if getent group "$SSH_GROUP" 1>/dev/null 2>&1; then
usermod --append --groups "$SSH_GROUP" "$in_login"
fi
fi
/etc/init.d/ssh reload
step_ok "Exécution du pre-script spécifique"
step_ok "Création des utilisateurs"
############################################################################
############################################################################
if [ -z "$HOME_DIR_USER" ]; then
HOME_DIR_USER="$HOME_DIR/$in_login"
fi
if [ "$WEB_SERVER" == "apache" ]; then
echo "www-$login: $login" >> /etc/aliases
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
elif [ "$WEB_SERVER" == "nginx" ]; then
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
fi
newaliases
############################################################################
step_ok "Alias mail"
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
chmod 750 "$HOME_DIR_USER"/
[ -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"
# Répertoires par défaut
mkdir -p "$HOME_DIR_USER"/{log,www,awstats}
chown "$in_login":"$in_login" "$HOME_DIR_USER"/www
chgrp "$in_login" "$HOME_DIR_USER"/{log,awstats}
chmod 750 "$HOME_DIR_USER"/{log,www,awstats}
############################################################################
# Ajout des logs par defaut
touch "$HOME_DIR_USER"/log/access.log
touch "$HOME_DIR_USER"/log/error.log
touch "$HOME_DIR_USER"/log/php.log
chgrp "$in_login" "$HOME_DIR_USER"/log/access.log
chgrp "$in_login" "$HOME_DIR_USER"/log/error.log
if [ "$WEB_SERVER" == "apache" ]; then
chown www-"$in_login":"$in_login" "$HOME_DIR_USER"/log/php.log
fi
# There is no php.log for nginx ATM, it will go in error.log.
chmod 640 "$HOME_DIR_USER"/log/access.log
chmod 640 "$HOME_DIR_USER"/log/error.log
chmod 640 "$HOME_DIR_USER"/log/php.log
step_ok "Création du répertoire personnel"
/usr/sbin/adduser --gecos "User $in_login" --disabled-password "$in_login" --shell /bin/bash $OPT_UID $OPT_UID_ARG --force-badname --home "$HOME_DIR_USER" >/dev/null
[ -z "$in_sshkey" ] && echo "$in_login:$in_passwd" | chpasswd --md5
[ -z "$in_sshkey" ] || [ -n "$HOME_DIR_USER" ] && mkdir "$HOME_DIR_USER/.ssh" && echo "$in_sshkey" > "$HOME_DIR_USER/.ssh/authorized_keys" \
&& chmod -R u=rwX,g=,o= "$HOME_DIR_USER/.ssh/authorized_keys" && chown -R "$in_login":"$in_login" "$HOME_DIR_USER/.ssh"
############################################################################
/usr/sbin/adduser --disabled-password --home $HOME_DIR_USER/www \
--no-create-home --shell /bin/false --gecos "WWW $in_login" www-$in_login $OPT_WWWUID $OPT_WWWUID_ARG --ingroup $in_login --force-badname >/dev/null
if [ -n "$in_quota" ]; then
quota_soft=$(($(echo "$in_quota" |cut -f 1 -d:) * 1024 * 1024))
quota_hard=$(($(echo "$in_quota" |cut -f 2 -d:) * 1024 * 1024))
setquota --remote --user "$in_login" $quota_soft $quota_hard 0 0 /home
fi
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
/etc/init.d/ssh reload
############################################################################
step_ok "Création des utilisateurs"
# Create FPM pool on all containers.
for php_version in "${PHP_VERSIONS[@]}"; do
if [ "$php_version" = "70" ]; then
pool_path="/etc/php/7.0/fpm/pool.d/"
elif [ "$php_version" = "73" ]; then
pool_path="/etc/php/7.3/fpm/pool.d/"
elif [ "$php_version" = "74" ]; then
pool_path="/etc/php/7.4/fpm/pool.d/"
elif [ "$php_version" = "80" ]; then
pool_path="/etc/php/8.0/fpm/pool.d/"
elif [ "$php_version" = "81" ]; then
pool_path="/etc/php/8.1/fpm/pool.d/"
elif [ "$php_version" = "82" ]; then
pool_path="/etc/php/8.2/fpm/pool.d/"
else
pool_path="/etc/php5/fpm/pool.d/"
fi
phpfpm_socket_path="/home/${in_login}/php-fpm${php_version}.sock"
cat <<EOT >/var/lib/lxc/php"${php_version}"/rootfs/${pool_path}/"${in_login}".conf
[${in_login}]
user = www-${in_login}
group = ${in_login}
############################################################################
listen = ${phpfpm_socket_path}
listen.owner = ${in_login}
listen.group = ${in_login}
echo "www-$login: $login" >> /etc/aliases
echo "$login: $WWWBOUNCE_MAIL" >> /etc/aliases
newaliases
pm = ondemand
pm.status_path = /evolinux_fpm_status-$(apg -Mncl -n1 -m32)
pm.max_children = 10
pm.process_idle_timeout = 10s
step_ok "Alias mail"
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
############################################################################
############################################################################
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 www-$in_login:$in_login $HOME_DIR_USER/log/php.log
chmod 640 $HOME_DIR_USER/log/access.log
chmod 640 $HOME_DIR_USER/log/error.log
chmod 640 $HOME_DIR_USER/log/php.log
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
step_ok "Création du répertoire personnel"
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"
############################################################################
random=$RANDOM
vhostfile="/etc/apache2/sites-available/${in_login}.conf"
cat $TPL_VHOST | \
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
a2ensite $in_login >/dev/null
step_ok "Configuration d'Apache"
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
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
a2ensite "${in_login}.conf" >/dev/null
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 "Configuration d'Apache"
step_ok "Activation d'Awstats"
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"
############################################################################
if [ "$in_dbname" ]; then
echo "CREATE DATABASE \`$in_dbname\` $MYSQL_CREATE_DB_OPTS;" | mysql
echo "GRANT ALL PRIVILEGES ON \`$in_dbname\`.* TO \`$in_login\`@localhost IDENTIFIED BY '$in_dbpasswd';" | mysql
echo "FLUSH PRIVILEGES;" | mysql
/etc/init.d/nginx restart
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 "Configuration de Nginx + restart"
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"
sed -e "s/SED_LOGIN/${in_login}/g;" \
< $TPL_FPM > ${FPM_PATH}/"${in_login}".conf
step_ok "Creation du pool PHP-FPM"
step_ok "Envoi du mail récapitulatif"
############################################################################
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
if [ -f $LOCAL_SCRIPT ]; then
source $LOCAL_SCRIPT
fi
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
step_ok "Exécution du script spécifique"
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
############################################################################
apache2ctl configtest 2>/dev/null
/etc/init.d/apache2 force-reload >/dev/null
step_ok "Activation d'Awstats"
step_ok "Rechargement d'Apache"
############################################################################
############################################################################
DATE=$(date +"%Y-%m-%d")
echo "$DATE [web-add.sh] Ajout $in_login" >> /var/log/evolix.log
if [ "$in_dbname" ]; then
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 $MYSQL_OPTS
echo "FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS
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
############################################################################
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#" \
< $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"
############################################################################
if [ -f $LOCAL_SCRIPT ]; then
# shellcheck source=/usr/share/scripts/evoadmin/web-add.local.sh
source $LOCAL_SCRIPT
fi
step_ok "Exécution du script spécifique"
############################################################################
if [ "$WEB_SERVER" == "apache" ]; then
apache2ctl configtest 2>/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"
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")
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
#
# Mode interactif
#
set -x
userdel $login
userdel www-$login
groupdel $login
sed -i.bak "/^$login:/d" /etc/aliases
sed -i.bak "/^www-$login:/d" /etc/aliases
if [ $# -eq 0 ]; then
echo
echo "Suppression d'un compte WEB"
echo
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
until [ "$login" ]; do
echo -n "Entrez le login du compte à supprimer : "
read -r tmp
login="$tmp"
done
a2dissite $login
rm /etc/apache2/sites-available/$login.conf
rm /etc/awstats/awstats.$login.conf
sed -i.bak "/-config=$login /d" /etc/cron.d/awstats
apache2ctl configtest
set +x
echo -n "Voulez-vous aussi supprimer un compte/base MySQL ? [y|N]"
read -r confirm
if [ -n "$dbname" ]; then
echo "Deleting mysql DATABASE $dbname and mysql user $login. Continue ?"
read
if [ "$confirm" = "y" ] || [ "$confirm" = "Y" ]; then
echo -n "Entrez le nom de la base de donnees ($login par defaut) : "
read -r tmp
set -x
echo "DROP DATABASE $dbname; delete from mysql.user where user='$login' ; FLUSH PRIVILEGES;" | mysql
set +x
fi
if [ -z "$tmp" ]; then
dbname=$login
else
dbname="$tmp"
fi
fi
#
# Mode non interactif
#
else
while getopts hy opt; do
case "$opt" in
y)
force_confirm=1
;;
h)
usage
exit 1
;;
?)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ $# -gt 0 ] && [ $# -le 2 ]; then
login=$1
if [ $# -eq 2 ]; then
dbname=$2
fi
else
usage
exit 1
fi
fi
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
set -x
# Crontab dump needs to be done **before** user deletion
if crontab -l -u "$login"; then
crontab -l -u "$login" &> /home/$login/crontab-$(date '+%Y%m%d-%H%M%S').bak
crontab -r -u "$login"
fi
# Deactivate web vhost (apache or nginx)
if [ "$WEB_SERVER" == "apache" ]; then
if a2query -s "${login}" >/dev/null 2&>1; then
a2dissite "${login}.conf"
fi
rm -f /etc/apache2/sites-available/"$login.conf"
apache2ctl configtest
for php_version in "${PHP_VERSIONS[@]}"; do
if [ "$php_version" = "70" ]; then
phpfpm_dir="/etc/php/7.0/fpm/pool.d/"
initscript_path="/etc/init.d/php7.0-fpm"
elif [ "$php_version" = "73" ]; then
phpfpm_dir="/etc/php/7.3/fpm/pool.d/"
initscript_path="/etc/init.d/php7.3-fpm"
elif [ "$php_version" = "74" ]; then
phpfpm_dir="/etc/php/7.4/fpm/pool.d/"
initscript_path="/etc/init.d/php7.4-fpm"
elif [ "$php_version" = "80" ]; then
phpfpm_dir="/etc/php/8.0/fpm/pool.d/"
initscript_path="/etc/init.d/php8.0-fpm"
elif [ "$php_version" = "81" ]; then
phpfpm_dir="/etc/php/8.1/fpm/pool.d/"
initscript_path="/etc/init.d/php8.1-fpm"
elif [ "$php_version" = "82" ]; then
phpfpm_dir="/etc/php/8.2/fpm/pool.d/"
initscript_path="/etc/init.d/php8.2-fpm"
else
phpfpm_dir="/etc/php5/fpm/pool.d/"
initscript_path="/etc/init.d/php5-fpm"
fi
rm -f /var/lib/lxc/php"${php_version}"/rootfs/${phpfpm_dir}/"${login}".conf
lxc-attach -n php"${php_version}" -- $initscript_path restart >/dev/null
done
elif [ "$WEB_SERVER" == "nginx" ]; then
rm -f /etc/nginx/sites-{available,enabled}/"$login"
rm -f /etc/munin/plugins/phpfpm_"${in_login}"*
nginx -t
fi
rm -f /etc/awstats/awstats."$login.conf"
sed -i.bak "/-config=$login /d" /etc/cron.d/awstats
if [ "$WEB_SERVER" == "apache" ]; then
if id www-"$login" &> /dev/null; then
userdel -f www-"$login"
fi
for php_version in "${PHP_VERSIONS[@]}"; do
if lxc-attach -n php"${php_version}" -- getent passwd www-"$login" &> /dev/null; then
lxc-attach -n php"${php_version}" -- userdel -f www-"$login"
fi
if lxc-attach -n php"${php_version}" -- getent passwd "$login" &> /dev/null; then
lxc-attach -n php"${php_version}" -- userdel -f "$login"
fi
done
fi
if getent passwd "$login" &> /dev/null; then
userdel -f "$login"
fi
sed -i.bak "/^$login:/d" /etc/aliases
if [ "$WEB_SERVER" == "apache" ]; then
sed -i.bak "/^www-$login:/d" /etc/aliases
fi
if grep -qE '^AllowUsers' /etc/ssh/sshd_config; then
sed -i "s/^AllowUsers .*/& $in_login/" /etc/ssh/sshd_config
/etc/init.d/ssh reload
fi
if [ -d "$HOME_DIR/$login" ]; then
mv -i $HOME_DIR/"$login" $HOME_DIR/"$login"."$(date '+%Y%m%d-%H%M%S')".bak
else
echo "warning : $HOME_DIR/$login does not exist"
fi
if [ -d /etc/letsencrypt/"$login" ]; then
rm -r /etc/letsencrypt/"$login"
fi
set +x
if [ -n "$dbname" ]; then
set -x
echo "DROP DATABASE \`$dbname\`; DROP USER \`$login\`@localhost; FLUSH PRIVILEGES;" | mysql $MYSQL_OPTS
set +x
fi
}
op_setphpversion() {
if [ $# -ne 2 ]; then
usage
exit 1
fi
login="$1"
phpversion="$2"
validate_phpversion "$phpversion"
sed -i "s#^\\(\s*SetHandler proxy:unix:/home/.*/php-fpm\\)..\\(\\.sock\\)#\\1${phpversion}\\2#" /etc/apache2/sites-available/"${login}".conf
sed -i "s#^\\(\s*<Proxy .*unix:/home/.*/php-fpm\\)..\\(\\.sock\\)#\\1${phpversion}\\2#" /etc/apache2/sites-available/"${login}".conf
/etc/init.d/apache2 force-reload >/dev/null
DATE=$(date +"%Y-%m-%d")
echo "$DATE [web-add.sh] PHP version set to $phpversion for $login" >> /var/log/evolix.log
}
op_setquota() {
if [ $# -ne 2 ]; then
usage
exit 1
fi
login="$1"
quota="$2"
validate_quota "$quota"
quota_soft=$(($(echo "$quota" |cut -f 1 -d:) * 1024 * 1024))
quota_hard=$(($(echo "$quota" |cut -f 2 -d:) * 1024 * 1024))
setquota --remote --user "$login" $quota_soft $quota_hard 0 0 /home
DATE=$(date +"%Y-%m-%d")
echo "$DATE [web-add.sh] quota set to $quota for $login" >> /var/log/evolix.log
}
arg_processing() {
# 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 $*
;;
# 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 "$@"
;;
check-vhosts)
op_checkvhosts "$@"
;;
add-alias)
op_aliasadd $*
op_aliasadd "$@"
;;
del-alias)
op_aliasdel $*
op_aliasdel "$@"
;;
*)
usage
;;
esac
fi
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
;;
esac
fi
}
op_makecsr() {
if [ $# -gt 1 ]; then
vhost="$1"
domains=""
# remove the first argument to keep only the domains
shift 1
for domain in "$@"; do
domains="${domains:+${domains} }${domain}"
done
# pipe the domains to make-csr because we don't have STDIN
echo "$domains" | make-csr "$vhost"
else usage
fi
}
op_generatesslcertificate() {
if [ $# -gt 1 ]; then
vhost="$1"
test_mode="$2"
if [ "$test_mode" = "false" ]; then
if [ -L /etc/letsencrypt/$vhost/live ]; then
rm /etc/letsencrypt/$vhost/live
fi
evoacme "$vhost"
else
DRY_RUN=1 evoacme "$vhost"
fi
else usage
fi
}
op_managehttpchallengefile() {
if [ $# -eq 1 ]; then
folder="/var/lib/letsencrypt/.well-known"
file="testfile"
action=${1};
if [ "$action" = "create" ]; then
if [ ! -d "$folder" ]; then
mkdir -p "$folder/acme-challenge"
fi
if [ ! -f "$folder/acme-challenge/$file" ]; then
touch "$folder/acme-challenge/$file"
fi
chmod -R 755 "$folder"
elif [ "$action" = "delete" ]; then
rm -r "$folder"
else usage
fi
else usage
fi
}
op_listvhost() {
if [ $# -eq 1 ]; then
configlist="$VHOST_PATH/$1";
else
configlist="$VHOST_PATH/*";
fi
if [ $# -eq 1 ]; then
configlist="$VHOST_PATH/${1}.conf";
else
configlist="$VHOST_PATH/*";
fi
for configfile in $configlist; do
if [ -r "$configfile" ] && echo "$configfile" |grep -qvE "/(000-default|default-ssl|evoadmin)\\.conf$"; then
servername="$(awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' "$configfile" | head -n 1)"
serveraliases="$(perl -ne 'print "$1 " if /^[[:space:]]*ServerAlias (.*)/' "$configfile" | head -n 1)"
serveraliases="$(echo $serveraliases | sed 's/ \+/,/g')"
userid="$(awk '/^[[:space:]]*AssignUserID.*/ { print $3 }' "$configfile" | head -n 1)"
if [ -x /usr/bin/quota ]; then
size=$(quota --no-wrap --human-readable "$userid" |grep /home |awk '{print $2}')
quota_soft=$(quota --no-wrap --human-readable "$userid" |grep /home |awk '{print $3}')
quota_hard=$(quota --no-wrap --human-readable "$userid" |grep /home |awk '{print $4}')
fi
phpversion=$(perl -lne 'print $1 if (m!^\s+SetHandler proxy:unix:/home/.*/php-fpm(\d{2})\.sock!)' "$configfile" | head -n 1)
if [ -e /etc/apache2/sites-enabled/"${userid}".conf ]; then
is_enabled=1
else
is_enabled=0
fi
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
count_virtualhosts="$(grep "<VirtualHost" "$configfile" | wc -l)"
if [ "$count_virtualhosts" -eq 1 ]; then
is_standard=1
else
is_standard=0
fi
if [ "$servername" ] && [ "$userid" ]; then
configid=$(basename "$configfile")
echo "$userid:$configid:$servername:$serveraliases:$size:$quota_soft:$quota_hard:$phpversion:$is_enabled:$is_standard"
fi
fi
done
}
op_aliasadd() {
if [ $# -eq 2 ]; then
vhost="${1}.conf"
alias=$2
vhost_file="${VHOST_PATH}/${vhost}"
[ -f $VHOST_PATH/$vhost ] && sed -i -e "s/\(ServerName .*\)/\1\n\tServerAlias $alias/" $VHOST_PATH/$vhost --follow-symlinks
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
/etc/init.d/apache2 force-reload >/dev/null
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
}
@ -454,192 +1087,364 @@ op_aliasdel() {
if [ $# -eq 2 ]; then
vhost="${1}.conf"
alias=$2
vhost_file="${VHOST_PATH}/${vhost}"
[ -f $VHOST_PATH/$vhost ] && sed -i -e "/ServerAlias $alias/d" $VHOST_PATH/$vhost --follow-symlinks
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
/etc/init.d/apache2 force-reload >/dev/null
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
else usage
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else
usage
fi
}
op_servernameupdate() {
if [ $# -eq 3 ]; then
vhost="${1}.conf"
servername=$2
old_servername=$3
vhost_file="${VHOST_PATH}/${vhost}"
if [ -f "${vhost_file}" ]; then
sed -i "/^ *ServerName/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks
sed -i "/^ *RewriteCond/ s/$old_servername/$servername/g" "${vhost_file}" --follow-symlinks
fi
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else
usage
fi
}
op_checkoccurencename() {
if [ $# -eq 1 ]; then
name=${1}
configlist="$VHOST_PATH/*";
servernames=''
aliases=''
for configfile in $configlist; do
if [ -r "$configfile" ]; then
alias=$(perl -ne 'print "$1 " if /^[[:space:]]*ServerAlias (.*)/' "$configfile" | head -n 1)
aliases="$aliases $alias"
servername=$(awk '/^[[:space:]]*ServerName (.*)/ { print $2 }' "$configfile" | uniq)
servernames="$servernames $servername"
fi
done
echo "$servernames" "$aliases" | grep -E "(^|\s)$name(\s|$)"
else
usage
fi
}
op_listuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH/${1}.conf"
awk '/AssignUserID/ {print $2}' "$configfile" | uniq
else
usage
fi
}
op_enableuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH/${1}.conf"
group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq)
sed -i "s/^ *AssignUserID $group/ AssignUserID www-$group/" "$configfile" --follow-symlinks
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else
usage
fi
}
op_disableuseritk() {
if [ $# -eq 1 ]; then
configfile="$VHOST_PATH"/"${1}".conf
group=$(awk '/AssignUserID/ {print $3}' "$configfile" | uniq)
sed -i "s/^ *AssignUserID www-$group/ AssignUserID ${group}/" "$configfile" --follow-symlinks
configtest_out=$(apache2ctl configtest)
configtest_rc=$?
if [ "$configtest_rc" = "0" ]; then
/etc/init.d/apache2 force-reload >/dev/null
else
echo $configtest_out >&2
fi
else
usage
fi
}
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
#
# 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 -r 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 -rs 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 -r 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 -r 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 -rs 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 -r tmp
if validate_wwwdomain "$tmp"; then
in_wwwdomain="$tmp"
fi
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
echo -n "Entrez votre adresse mail pour recevoir le mail de creation ($CONTACT_MAIL par défaut) : "
read -r 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:r:q: 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
;;
r)
in_phpversion=$OPTARG
;;
q)
in_quota=$OPTARG
;;
h)
usage
exit 1
;;
?)
usage
exit 1
;;
esac
done
shift $((OPTIND - 1))
if [ $# -ne 2 ]; then
usage
exit 1
else
in_login=$1
in_wwwdomain=$2
validate_login "$in_login" || exit 1
[ -z "$in_passwd" ] && [ -z "$in_sshkey" ] && in_passwd=$(gen_random_passwd)
[ -z "$in_sshkey" ] && ( validate_passwd "$in_passwd" || exit 1 )
[ -n "$in_dbname" ] && ( validate_dbname "$in_dbname" || exit 1 )
[ -z "$in_dbpasswd" ] && [ -n "$in_dbname" ] && in_dbpasswd=$(gen_random_passwd)
[ -n "$in_dbname" ] && ( validate_passwd "$in_dbpasswd" || exit 1 )
validate_wwwdomain "$in_wwwdomain" || exit 1
[ -z "$in_mail" ] && in_mail=$CONTACT_MAIL
validate_mail $in_mail || exit 1
[ -n "$in_phpversion" ] && (validate_phpversion "$in_phpversion" || exit 1)
[ -n "$in_quota" ] && (validate_quota "$in_quota" || exit 1)
fi
fi
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"
if [ ${#PHP_VERSIONS[@]} -gt 0 ]; then
echo "version de PHP : $in_phpversion"
fi
echo "Quota : $in_quota"
echo "Envoi du mail récapitulatif à : $in_mail"
echo "----------------------------------------------"
echo
if [ -z "$force_confirm" ]; then
echo -n "Confirmer la création ? [y/N] : "
read -r 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
}
# Some people forget to use the --follow-symlinks flag with sed(1),
# thus not carrying changes over to /etc/sites-available.
op_checkvhosts() {
ln_vhosts_dir="$(sed 's/available/enabled/' <<< "$VHOST_PATH")"
non_ln_vhosts="$(find "$ln_vhosts_dir"/* ! -type l)"
while getopts f opt; do
case "$opt" in
f)
apply=1
;;
?)
usage
exit 1
;;
esac
done
for ln_path in $non_ln_vhosts
do
vhost_name=$(basename "$ln_path")
fix_conf="mv $ln_path $VHOST_PATH/$vhost_name"
fix_ln="a2ensite ${vhost_name}.conf"
if [[ -z "$apply" ]]; then
echo "Suggested fixes for $vhost_name:"
echo "diff $ln_path $VHOST_PATH/$vhost_name"
echo "$fix_conf"
echo "$fix_ln"
else
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
$fix_conf
$fix_ln
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
done
}
# Return web-add.sh version
op_version(){
echo "$VERSION"
}
# Point d'entrée
arg_processing $*
arg_processing "$@"

View 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/

View file

@ -13,9 +13,7 @@
* @version 1.0
*/
?>
<?php
if(!empty($exec_info)) {
print '<pre>';
if ($conf['debug'] == TRUE)
@ -23,7 +21,7 @@
if ($exec_info[1]) {
print "La commande a <strong>échoué</strong>\n";
print_r($exec_info);
print_r($exec_info);
}
else print "Le compte a été créé avec succès\n";
@ -34,12 +32,21 @@
print '</pre>';
} 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">
<fieldset>
<legend>Ajout d'un compte</legend>
<?php print $form; ?>
<?= $form ?>
<p><input type="submit" value="Créer"/></p>
</fieldset>
</form>

View file

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

42
tpl/dbadmin.tpl.php Normal file
View 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">&nbsp;&nbsp;%s</td>', preg_replace("/'/", "", $db_info['owner']));
printf('<td align="left">&nbsp;&nbsp;%s</td>', $db_info['database']);
print '</tr>';
} ?>
</tbody>
</table>
<?php
} else {
print '<div class="alert alert-info" role="alert">Aucune base existante !</div>';
}
?>
</div>

View file

@ -21,7 +21,7 @@
<head>
<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" />
<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>
@ -31,10 +31,10 @@
<body>
<div id="main">
<h1 id="top">EvoAdmin
<h1 id="top">Evoadmin-web
<?php
if(!empty($_SESSION['user'])) {
print ' - '.$_SESSION['user'];
print ' v'.$_SESSION['cli_version'].' - '.$_SESSION['user'];
if(is_superadmin()) {
print ' (Administrateur)';

View file

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

View 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>

View file

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

58
tpl/webadmin-itk.tpl.php Normal file
View 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>";
}
?>

View 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
View 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>

View 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>";
}
?>

View file

@ -5,7 +5,7 @@
*
* Copyright (c) 2009 Evolix - Tous droits reserves
*
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
* vim: expandtab softtabstop=4 tabstop=4 shiftwidth=4 showtabline=2
*
* @author Gregory Colpart <reg@evolix.fr>
* @author Thomas Martin <tmartin@evolix.fr>
@ -15,16 +15,36 @@
?>
<h2>Domaines</h2>
<h2>Liste des comptes web</h2>
<?php if(count($vhost_list) > 0) { ?>
<table id="tab-list">
<thead>
<tr>
<?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>&nbsp;Utilisé&nbsp;</th>';
print '<th>&nbsp;Soft&nbsp;</th>';
print '<th>&nbsp;Hard&nbsp;</th>';
print '<th>&nbsp;Occupation&nbsp;</th>';
}
if (array_key_exists('php_versions', $conf) && count($conf['php_versions']) > 1) {
print '<th>&nbsp;PHP&nbsp;</th>';
}
?>
<th>&nbsp;Actif ?&nbsp;</th>
<?php if(is_superadmin()) {
print '<th>Administration</th>';
}
?>
<!--<th>Opérations</th>-->
<?php if($conf['cluster']) { ?>
<th>Bdd</th>
@ -32,10 +52,8 @@
<th>Replication</th>
<th>Master</th>
<th>Slave</th>
<?php if(is_superadmin()) {
print '<th>Alias</th>';
}} ?>
<tr>
<?php } ?>
</tr>
</thead>
<tbody>
<?php foreach($vhost_list as $vhost_info) {
@ -43,45 +61,72 @@
if(is_superadmin()) {
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']);
if ($conf['cluster']) {
if (empty($vhost_info['bdd']))
printf('<td bgcolor="#696969"/>');
else
printf('<td>%s</td>', $vhost_info['bdd']);
if (empty($vhost_info['bdd']))
printf('<td bgcolor="#696969"/>');
else
printf('<td>%s</td>', $vhost_info['bdd']);
if (empty($vhost_info['mail']))
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['mail']))
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
printf('<td>%s</td>', $vhost_info['replication']);
printf('<td>%s</td>', $vhost_info['master']);
if (empty($vhost_info['slave']))
printf('<td bgcolor="#696969"/>');
else
printf('<td>%s</td>', $vhost_info['slave']);
if (empty($vhost_info['replication']))
printf('<td bgcolor="#696969"/>');
else
printf('<td>%s</td>', $vhost_info['replication']);
printf('<td>%s</td>', $vhost_info['master']);
if (empty($vhost_info['slave']))
printf('<td bgcolor="#696969"/>');
else
printf('<td>%s</td>', $vhost_info['slave']);
}
else {
printf('<td>%s</td>', $vhost_info['server_alias']);
}
if (is_superadmin()) {
printf('<td><a href="/webadmin/edit/%s">Lister/Modifier</a></td>',
$vhost_info['owner']);
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()) {
printf('<td>');
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>');
}
print '</tr>';
} ?>
</tbody>
</table>
<br>
Nombre total de comptes : <?= count($vhost_list); ?>
<?php
} else {
print '<p>Aucun domaine existant !</p>';