mirror of
https://github.com/myvesta/vesta
synced 2025-07-06 04:51:54 -07:00
Compare commits
350 commits
0.9.8-26-6
...
master
Author | SHA1 | Date | |
---|---|---|---|
|
d20bc94866 | ||
|
b8b75f0dde | ||
|
2fd60fc29d | ||
|
1567383b49 | ||
|
6cce5ecadd | ||
|
e8b5b5a836 | ||
|
451c9944b9 | ||
|
f77f8e8b78 | ||
|
09465e5fba | ||
|
5ee72684ab | ||
|
d37473b5e8 | ||
|
fd6eb44bae | ||
|
97e5fc0677 | ||
|
294c8ba516 | ||
|
761da8150b | ||
|
2e2b4b2f58 | ||
|
e46c7e4e60 | ||
|
b13b25602c | ||
|
c8f9601a35 | ||
|
d1c48504ad | ||
|
596bce582f | ||
|
31413a8f73 | ||
|
6ac6ea40d3 | ||
|
12dc1a5718 | ||
|
8a4b66a135 | ||
|
a8e39817fc | ||
|
aa2f5e4fbb | ||
|
e8cbaa742f | ||
|
59053e2ffd | ||
|
4f871db1fc | ||
|
819450ca5c | ||
|
2fe4ce2ae4 | ||
|
c5d0619a6b | ||
|
413787070a | ||
|
6d752d93f5 | ||
|
85f39364a4 | ||
|
0fd5be1d28 | ||
|
89b7538fad | ||
|
8d9a3e1ca0 | ||
|
4932dd3bb4 | ||
|
213ccd47df | ||
|
a3895aea0d | ||
|
72252c561e | ||
|
435a362765 | ||
|
5ca293c9b2 | ||
|
92029a9733 | ||
|
de5365280f | ||
|
fa8dd64c5a | ||
|
ff7bc2baa5 | ||
|
4c495a1d69 | ||
|
cb6e8e4926 | ||
|
451b025f1f | ||
|
d3fb4e13d5 | ||
|
83d12510e3 | ||
|
6dccbb8276 | ||
|
7388432261 | ||
|
0d86e2ca40 | ||
|
8bdfade3d4 | ||
|
a86f76de09 | ||
|
57f179ad05 | ||
|
01e4890a97 | ||
|
4437f6f0da | ||
|
24908aede1 | ||
|
dc1979461e | ||
|
039dc4a561 | ||
|
32aae7dbff | ||
|
1573a33b75 | ||
|
7937088e9c | ||
|
c5e5464373 | ||
|
c1072ec9e4 | ||
|
0e881c911b | ||
|
9fdfe2760a | ||
|
2daa635cde | ||
|
0639e7765f | ||
|
3337783666 | ||
|
82803093d6 | ||
|
2e66899997 | ||
|
62b0e672a6 | ||
|
92ddd343a2 | ||
|
aa92b6a270 | ||
|
00ef25524d | ||
|
af8c071944 | ||
|
6a35d14f0c | ||
|
015b3c4571 | ||
|
a2ed0dbf7a | ||
|
74fecc45d3 | ||
|
0f71df9a95 | ||
|
15b5996e4f | ||
|
8c477c39bf | ||
|
a7d7c3686c | ||
|
2cbf37e4d1 | ||
|
e8c912513d | ||
|
5e9cf711e6 | ||
|
de2305b3ff | ||
|
60ce986ece | ||
|
5eb0607319 | ||
|
f5027aff5d | ||
|
46d2a729a1 | ||
|
24d84de6d2 | ||
|
89fc5a1ebd | ||
|
afc6b62d5c | ||
|
da84a0b913 | ||
|
24371b8bbf | ||
|
acfc563a6c | ||
|
e79acf1828 | ||
|
76ad95da64 | ||
|
c148a1ed79 | ||
|
c32bd2c709 | ||
|
3ed2cfa07b | ||
|
a99ae91c21 | ||
|
b9f89d0416 | ||
|
7dcaaace8a | ||
|
138f41c145 | ||
|
6e7954db55 | ||
|
1ee4920576 | ||
|
574fff0642 | ||
|
7ff828bf14 | ||
|
c1f7c91953 | ||
|
7fa725b893 | ||
|
72baf4c702 | ||
|
edf1f616b2 | ||
|
357b20cc52 | ||
|
30fb3d6a6c | ||
|
d59c4fafe2 | ||
|
67b8376608 | ||
|
6a72798aba | ||
|
8a8422539c | ||
|
7a13c03e9a | ||
|
a8435cab14 | ||
|
f99bcf8746 | ||
|
c3985ba95e | ||
|
21f7a509cb | ||
|
75ffd02ff9 | ||
|
e51cd34f77 | ||
|
abc2377dad | ||
|
9cf91d5535 | ||
|
491ac6255c | ||
|
81f507b3c4 | ||
|
763eea5c58 | ||
|
806ebf1db6 | ||
|
4acfa26de5 | ||
|
66ae5580cd | ||
|
dcd0bf2d64 | ||
|
05f5288d9b | ||
|
65d4f0e65e | ||
|
9b0f9e5876 | ||
|
cc3437c287 | ||
|
9d65824606 | ||
|
6514ea1d38 | ||
|
f540cf9f2a | ||
|
40afd5b5c8 | ||
|
929241c5f7 | ||
|
583a1e5cc7 | ||
|
63c4826ac0 | ||
|
8cc35b43eb | ||
|
dd825b96cb | ||
|
5acdfb6158 | ||
|
55e0fcb5de | ||
|
20695198f4 | ||
|
dd18d6dd6d | ||
|
fa165a0020 | ||
|
0ae1ea6adc | ||
|
e6bf09c608 | ||
|
138a30755f | ||
|
6819f21c3e | ||
|
a7def7b190 | ||
|
7e209c543d | ||
|
2aca86432f | ||
|
edfea0d259 | ||
|
560fa67c4b | ||
|
db7e663c2c | ||
|
11ab872123 | ||
|
7274147d36 | ||
|
22463fd0f1 | ||
|
e9317fc0ae | ||
|
834fcfcf12 | ||
|
a43eef9c9b | ||
|
cf1eacde1d | ||
|
b0b3a9403f | ||
|
003f35810b | ||
|
1a6562eb87 | ||
|
f400b401d2 | ||
|
ecf419cb88 | ||
|
bdde36d4e3 | ||
|
c3720e5d5e | ||
|
add9c5c5e7 | ||
|
8ef3fb0357 | ||
|
08d0db0c6f | ||
|
db6ba149c6 | ||
|
942b46a657 | ||
|
a55b160103 | ||
|
5e72ead3b3 | ||
|
f39dc8edce | ||
|
f344c0b1d5 | ||
|
6800013edb | ||
|
cecb7cf56a | ||
|
e1053b1c9a | ||
|
0beaa0abda | ||
|
fa71d3a1c6 | ||
|
91f6ae080a | ||
|
328f6f293c | ||
|
f4beb1c8f1 | ||
|
c4eb89e4fd | ||
|
25749e8025 | ||
|
5e3473f90d | ||
|
65aa97de82 | ||
|
9985fcbea5 | ||
|
fc05c65359 | ||
|
fff40883dd | ||
|
562ad763dd | ||
|
7993d50276 | ||
|
803cde4c89 | ||
|
5e525f8898 | ||
|
88f52ec9a4 | ||
|
3d8880e559 | ||
|
911dc91268 | ||
|
c87de2631b | ||
|
bfdefc50e3 | ||
|
2f0807e8ee | ||
|
946a1953d9 | ||
|
bf8411fa08 | ||
|
3f3cfece06 | ||
|
8748ffc85b | ||
|
a4acb57e54 | ||
|
1848c36784 | ||
|
af7b658bfb | ||
|
9c233e92a6 | ||
|
fd57420a70 | ||
|
baa93199e8 | ||
|
5fb32ef55f | ||
|
1099b0c267 | ||
|
b5d57baa29 | ||
|
64fa7d9e58 | ||
|
e1fe2ba094 | ||
|
85bbc56cbd | ||
|
3d503f4e14 | ||
|
33e6263e3d | ||
|
8a323f6447 | ||
|
c8fcc089a7 | ||
|
98d8ab7f29 | ||
|
1709e9ae3d | ||
|
39a4dffbce | ||
|
c43b3b0976 | ||
|
06527b4d49 | ||
|
022f3078f5 | ||
|
8d467b98ab | ||
|
34c0588b76 | ||
|
b80a975621 | ||
|
c32036e531 | ||
|
658680095b | ||
|
bb79f9f8c0 | ||
|
0213d749ee | ||
|
cb52ef65b4 | ||
|
4d7ce60f39 | ||
|
e82378c935 | ||
|
843d4a94e2 | ||
|
5d2f0d68e0 | ||
|
12d6e59a7e | ||
|
7ee011a9d3 | ||
|
ef5ef95194 | ||
|
dc8abe95f0 | ||
|
12c65839c2 | ||
|
d4f0baa4ad | ||
|
9290ba6071 | ||
|
e095751b8b | ||
|
fb3e1e52e0 | ||
|
a6eedcc6a9 | ||
|
ac98e1d9aa | ||
|
c41a540494 | ||
|
473277dd29 | ||
|
d41ca32761 | ||
|
ebd100521f | ||
|
fdff356aa7 | ||
|
b3336ba630 | ||
|
82956ffa9e | ||
|
1d89e935e1 | ||
|
599ce37116 | ||
|
93a6d0b6e9 | ||
|
ce5fac9b07 | ||
|
c74dfde170 | ||
|
d52e27cc05 | ||
|
a6fdb87f7d | ||
|
b535c863d6 | ||
|
89c86b84fd | ||
|
83092b8ac8 | ||
|
159755e053 | ||
|
58c2793e94 | ||
|
420c0d097f | ||
|
f332227588 | ||
|
f6cb92c20a | ||
|
698069d708 | ||
|
af61d62c47 | ||
|
b5ccfbed82 | ||
|
b421b5f3b6 | ||
|
21071f4d7a | ||
|
90fddaa436 | ||
|
ef368b644b | ||
|
6e88a26d4d | ||
|
db6360922f | ||
|
83acec3ec1 | ||
|
83649defc9 | ||
|
83e24f738a | ||
|
6921a58418 | ||
|
8fd8e33c3f | ||
|
5cbbbbcb06 | ||
|
9c9c06c2dc | ||
|
bae14b2180 | ||
|
04070b4270 | ||
|
d9a68455a8 | ||
|
7875aaf58e | ||
|
0a5faad911 | ||
|
b41131f7ba | ||
|
eccd4a99ba | ||
|
1120629026 | ||
|
4683c08e1b | ||
|
b670feea43 | ||
|
fcdd2a552c | ||
|
bf56cdc40f | ||
|
39745fd25a | ||
|
ecb988d2eb | ||
|
cd6c585641 | ||
|
524a3a592b | ||
|
ff61a26f69 | ||
|
2a3de783ae | ||
|
8bead4afaa | ||
|
c3d0c17c51 | ||
|
2afbc2cddf | ||
|
ec8e174158 | ||
|
c2511876c2 | ||
|
22d524cfce | ||
|
ae45e4a571 | ||
|
502acb44c0 | ||
|
075c5e231b | ||
|
3fbb3dad78 | ||
|
b01da84b15 | ||
|
888db2bc72 | ||
|
2f37124545 | ||
|
c5144bcbae | ||
|
452f8a81d9 | ||
|
4dd6d22f07 | ||
|
77467eeebd | ||
|
706e365a5e | ||
|
2fae00ae7d | ||
|
e2fcade5bb | ||
|
8dbfa3e210 | ||
|
0e16d8d59c | ||
|
f0a82f02d3 | ||
|
e86585568d | ||
|
5eabdd4784 | ||
|
863f3e2aa5 |
472 changed files with 24574 additions and 2964 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -4,3 +4,6 @@
|
||||||
*.gz
|
*.gz
|
||||||
.vscode
|
.vscode
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
data
|
||||||
|
conf
|
||||||
|
log
|
40
Changelog.md
40
Changelog.md
|
@ -1,3 +1,43 @@
|
||||||
|
Version 0.9.9-0-12 [28-Feb-2025]
|
||||||
|
==================================================
|
||||||
|
* SpamHaus DNSBL removed from exim4
|
||||||
|
* A lot of small bugs fixed
|
||||||
|
|
||||||
|
Version 0.9.9-0-11 [30-May-2024]
|
||||||
|
==================================================
|
||||||
|
* Introducing v-run-wp-cli command ( @isscbta )
|
||||||
|
* Introducing v-add-wordpress-admin command ( @isscbta )
|
||||||
|
* Few bugs fixed
|
||||||
|
|
||||||
|
Version 0.9.9-0-10 [11-Apr-2024]
|
||||||
|
==================================================
|
||||||
|
* Introducing v-edit-php-ini command ( @isscbta )
|
||||||
|
* Introducing v-edit-domain-php-ini command ( @isscbta )
|
||||||
|
|
||||||
|
Version 0.9.9-0-9 [05-Apr-2024]
|
||||||
|
==================================================
|
||||||
|
* Get quick info about a banned IP (Host, Banlist, Location) (many thanks to @VasilisParaschos )
|
||||||
|
* Few bugs fixed
|
||||||
|
|
||||||
|
Version 0.9.9-0-5 to 0.9.9-0-8
|
||||||
|
==================================================
|
||||||
|
* Few bugs fixed
|
||||||
|
|
||||||
|
Version 0.9.9-0-4 [27-Jun-2023]
|
||||||
|
==================================================
|
||||||
|
* Support for Debian 12 ( in mutual cooperation with @HestiaCP )
|
||||||
|
|
||||||
|
Version 0.9.9-0-2 [12-Jun-2023]
|
||||||
|
==================================================
|
||||||
|
* Hosting panel UI perfomance fix
|
||||||
|
|
||||||
|
Version 0.9.9-0 [05-Jun-2023]
|
||||||
|
==================================================
|
||||||
|
* Redesign of hosting panel
|
||||||
|
* Fix for WP_CACHE_KEY_SALTs in v-clone-website command
|
||||||
|
* Fix for "Helo name contains a ip address" in Exim4
|
||||||
|
* Fix for Exim4 for punycode domains (in collaboration with @HestiaCP )
|
||||||
|
|
||||||
Version 0.9.8-26-62 [05-Apr-2023]
|
Version 0.9.8-26-62 [05-Apr-2023]
|
||||||
==================================================
|
==================================================
|
||||||
* Fix for LetsEncrypt Asynchronous Order Finalization (in collaboration with @HestiaCP )
|
* Fix for LetsEncrypt Asynchronous Order Finalization (in collaboration with @HestiaCP )
|
||||||
|
|
101
README.md
101
README.md
|
@ -1,14 +1,95 @@
|
||||||
myVesta
|
|
||||||
==================================================
|
|
||||||
|
|
||||||
Visit our homepage:
|
<h1 align="center"><a href="https://myvestacp.com">myVesta</a></h1>
|
||||||
- https://www.myvestacp.com/
|
|
||||||
|
|
||||||
Forum:
|
<div style="text-align:center">
|
||||||
- https://forum.myvestacp.com/
|
|
||||||
|
[](https://www.myvestacp.com/)
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<h1 align="center">About</h1>
|
||||||
|
|
||||||
|
<p align="center">myVesta is a security and stability-focused fork of VestaCP, exclusively supporting Debian in order to maintain a streamlined ecosystem. Boasting a clean, clutter-free interface and the latest innovative technologies, our project is committed to staying synchronized with official VestaCP commits. We work independently to enhance security and develop new features, driven by our passion for contributing to the open-source community rather than monetary gain. As such, we will offer all features built for myVesta to the official VestaCP project through pull requests, without interfering with their development milestones.</p>
|
||||||
|
|
||||||
|
<p align="center"><b><a href="https://github.com/myvesta/vesta/blob/master/Changelog.md">View Changelog</a>
|
||||||
|
</b></p>
|
||||||
|
|
||||||
|
<h1>Links</h1>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://www.myvestacp.com/">Visit our homepage.</a></li>
|
||||||
|
<li><a href="https://forum.myvestacp.com/">Check out our forum for discussions and support.</a></li>
|
||||||
|
<li><a href="https://wiki.myvestacp.com/">For more information, take a look at our knowledge base.</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1>Features of myVesta</h1>
|
||||||
|
<ul>
|
||||||
|
<li>Support for Debian 11 and 12 (Debian 12 is recommended, but previous Debian releases are also supported)</li>
|
||||||
|
<li>Support for MySQL 8</li>
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=20&t=51">nginx templates</a> that can prevent denial-of-service on your server</li>
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=18&t=52">Support for multi-PHP versions</a></li>
|
||||||
|
<li>You can <a href="https://forum.myvestacp.com/viewtopic.php?f=20&t=350">host NodeJS apps</a></li>
|
||||||
|
<li>You can limit the maximum number of sent emails (per hour) <a href="https://github.com/myvesta/vesta/blob/master/install/debian/10/exim/exim4.conf.template#L112-L113">per mail account</a> and <a href="https://github.com/myvesta/vesta/blob/master/install/debian/10/exim/exim4.conf.template#L72-L73">per hosting account</a>, preventing hijacking of email accounts and preventing PHP malware scripts to send spam.</li>
|
||||||
|
<li>
|
||||||
|
You can completely "lock" myVesta so it can be accessed only via secret URL, for example https://serverhost:8083/?MY-SECRET-URL
|
||||||
|
<ul>
|
||||||
|
<li>During installation you will be asked to choose a secret URL for your hosting panel</li>
|
||||||
|
<li>Literally no PHP scripts will be alive on your hosting panel (won't be able to get executed), unless you access the hosting panel with secret URL parameter. Thus, when it happens that, let's say, some zero-day exploit pops up - attackers won't be able to access it without knowing your secret URL - PHP scripts from VestaCP will be simply dead - no one will be able to interact with your panel unless they have the secret URL.</li>
|
||||||
|
<li>You can see for yourself how this mechanism was built by looking at:</li>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://github.com/myvesta/vesta/blob/master/src/deb/for-download/php/php.ini#L496">src/deb/for-download/php/php.ini</a></li>
|
||||||
|
<li><a href="https://github.com/myvesta/vesta/blob/master/web/inc/secure_login.php">web/inc/secure_login.php</a></li>
|
||||||
|
</ul>
|
||||||
|
<li>If you didn't set the secret URL during installation, you can do it anytime. Just execute in shell: <code>echo "<?php \$login_url='MY-SECRET-URL';" > /usr/local/vesta/web/inc/login_url.php</code></li>
|
||||||
|
</ul>
|
||||||
|
</li>
|
||||||
|
<li>We <a href="https://github.com/myvesta/vesta/blob/master/install/debian/10/php/php7.3-dedi.patch#L9">disabled dangerous PHP functions</a> in php.ini, so even if, for example, your customer's CMS gets compromised, hacker will not be able to execute shell scripts from within PHP.</li>
|
||||||
|
<li>Apache is fully switched to mpm_event mode, while PHP is running in PHP-FPM mode, which is the most stable PHP-stack solution
|
||||||
|
<ul><li>OPCache is turned on by default</li></ul>
|
||||||
|
<li>Auto-generating LetsEncrypt SSL for server hostname (signed SSL for Vesta 8083 port, for dovecot (IMAP & POP3) and for Exim (SMTP))</li>
|
||||||
|
<li>You can change Vesta port during installation or later using one command line: v-change-vesta-port [number]</li>
|
||||||
|
<li>ClamAV is configured to block zip/rar/7z archives that contains executable files (just like GMail)</li>
|
||||||
|
<li>Backup will run with lowest priority (to avoid load on server), and can be configured to run only by night (and to stop on the morning and continue next night) </li>
|
||||||
|
<ul>
|
||||||
|
<li>You can compile Vesta binaries by yourself - <a href="https://github.com/myvesta/vesta/blob/master/src/deb/vesta_compile.sh">src/deb/vesta_compile.sh</a></li>
|
||||||
|
<li>You can even create your own APT repository in a minute</li>
|
||||||
|
<li>We are using latest nginx version for vesta-nginx package</li>
|
||||||
|
<li>With your own APT infrastructure you can take security of Vesta-installer infrastructure in your own hands. You will have full control of your Vesta code (this way you can rest assured that there's 0% chance that you'll install malicious packages from repositories that may get hacked)</li>
|
||||||
|
<li>Binaries that you compile are 100% compatible with official VestaCP from vestacp.com, so you can run official VestaCP code with your own binaries (in case you don't want the source code from this fork)</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<h1>How to install</h1>
|
||||||
|
Download the installation script:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
curl -O http://c.myvestacp.com/vst-install-debian.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Then run it:
|
||||||
|
|
||||||
|
```shell
|
||||||
|
bash vst-install-debian.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
Or use our <a href="https://www.myvestacp.com/install_generator.html">installer generator</a>.
|
||||||
|
|
||||||
|
<h1>Useful scripts</h1>
|
||||||
|
<ul>
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=24&t=50">How to move accounts from one (my)Vesta server to another myVesta server</a></li>
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=17&t=386">WordPress installer in one second </a></li>(v-install-wordpress)
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=17&t=385">Cloning script that will copy the whole site from one (sub)domain to another (sub)domain </a></li>(v-clone-website)
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=17&t=382">Script that will migrate your site from http to https, replacing http to https URLs in database </a></li>(v-migrate-site-to-https)
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=24&t=63">Script for importing cPanel backups to Vesta (thanks to Maks Usmanov - Skamasle) </a></li> (v-import-cpanel-backup)
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=18&t=52">Script that will install multiple PHP versions on your server</a></li>
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=20&t=350">How to host NodeJS apps</a></li>
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=20&t=51">Script that will install nginx templates that can prevent denial-of-service on your server</a></li>
|
||||||
|
<li><a href="https://forum.myvestacp.com/viewtopic.php?f=15&t=47">Official VestaCP Softaculous installer</a></li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
|
||||||
|
<h1>Licence</h1>
|
||||||
|
myVesta is licensed under <a href="https://github.com/serghey-rodin/vesta/blob/master/LICENSE">GPL v3</a> license.
|
||||||
|
|
||||||
Knowledge base:
|
|
||||||
- https://wiki.myvestacp.com/
|
|
||||||
|
|
||||||
Changelog:
|
|
||||||
- https://github.com/myvesta/vesta/blob/master/Changelog.md
|
|
||||||
|
|
|
@ -126,7 +126,7 @@ else
|
||||||
chown $user:$user /home/$user/web/$domain/cron.log
|
chown $user:$user /home/$user/web/$domain/cron.log
|
||||||
|
|
||||||
case $fpm_ver in
|
case $fpm_ver in
|
||||||
5.6 | 7.0 | 7.1 | 7.2 | 7.3 | 7.4 | 8.0 | 8.1 | 8.2)
|
5.6 | 7.0 | 7.1 | 7.2 | 7.3 | 7.4 | 8.0 | 8.1 | 8.2 | 8.3)
|
||||||
/usr/local/vesta/bin/v-add-cron-job "$user" "*/15" "*" "*" "*" "*" "cd /home/$user/web/$domain/public_html; /usr/bin/php$fpm_ver wp-cron.php >/home/$user/web/$domain/cron.log 2>&1"
|
/usr/local/vesta/bin/v-add-cron-job "$user" "*/15" "*" "*" "*" "*" "cd /home/$user/web/$domain/public_html; /usr/bin/php$fpm_ver wp-cron.php >/home/$user/web/$domain/cron.log 2>&1"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
|
@ -72,6 +72,13 @@ $iptables -I fail2ban-$chain 1 -s $ip \
|
||||||
# Changing permissions
|
# Changing permissions
|
||||||
chmod 660 $conf
|
chmod 660 $conf
|
||||||
|
|
||||||
|
# nginx deny rules conf
|
||||||
|
if [ "$chain" = "WEB" ] && [ -f "/etc/nginx/conf.d/block.conf" ]; then
|
||||||
|
if ! grep -q "deny $ip;" /etc/nginx/conf.d/block.conf; then
|
||||||
|
echo "deny $ip;" >> /etc/nginx/conf.d/block.conf
|
||||||
|
systemctl reload nginx
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
|
|
|
@ -83,6 +83,16 @@ sort_fw_rules
|
||||||
# Updating system firewall
|
# Updating system firewall
|
||||||
$BIN/v-update-firewall
|
$BIN/v-update-firewall
|
||||||
|
|
||||||
|
if [ "$WEB_SYSTEM" == 'nginx' ] || [ "$PROXY_SYSTEM" == 'nginx' ]; then
|
||||||
|
if [ "$port_ext" == "80,443" ] && [ "$action" == "DROP" ]; then
|
||||||
|
touch /etc/nginx/conf.d/block-firewall.conf
|
||||||
|
if ! grep -q "deny $ip;" /etc/nginx/conf.d/block-firewall.conf; then
|
||||||
|
echo "deny $ip;" >> /etc/nginx/conf.d/block-firewall.conf
|
||||||
|
systemctl restart nginx
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
|
|
|
@ -21,6 +21,8 @@ if [[ "$LE_STAGING" = 'yes' ]]; then
|
||||||
API='https://acme-staging-v02.api.letsencrypt.org'
|
API='https://acme-staging-v02.api.letsencrypt.org'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
deb_release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -60,7 +62,11 @@ query_le_v2() {
|
||||||
# Save http response to file passed as "$4" arg or print to stdout if not provided
|
# Save http response to file passed as "$4" arg or print to stdout if not provided
|
||||||
# http response headers are always sent to stdout
|
# http response headers are always sent to stdout
|
||||||
local save_to_file=${4:-"/dev/stdout"}
|
local save_to_file=${4:-"/dev/stdout"}
|
||||||
curl --location --user-agent "myVesta" --insecure --retry 5 --retry-connrefused --silent --dump-header /dev/stdout --data "$post_data" "$1" --header "$content" --output "$save_to_file"
|
if [ "$deb_release" -gt 8 ]; then
|
||||||
|
curl --location --user-agent "myVesta" --insecure --retry 5 --retry-connrefused --silent --dump-header /dev/stdout --data "$post_data" "$1" --header "$content" --output "$save_to_file"
|
||||||
|
else
|
||||||
|
curl --location --user-agent "myVesta" --insecure --retry 5 --silent --dump-header /dev/stdout --data "$post_data" "$1" --header "$content" --output "$save_to_file"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -148,6 +154,11 @@ for identifier in $(echo $domain,$aliases |tr ',' '\n' |sort -u); do
|
||||||
done
|
done
|
||||||
payload=$(echo "$payload"|sed "s/,$//")
|
payload=$(echo "$payload"|sed "s/,$//")
|
||||||
payload=$payload']}'
|
payload=$payload']}'
|
||||||
|
# validation='pending'
|
||||||
|
# # Start counter to avoid infinite loop
|
||||||
|
# i=0
|
||||||
|
# while [ "$validation" = 'pending' ]; do
|
||||||
|
# echo "[$(date)] : ----------------------- step 2 loop, counter \$i=$i -----------------------" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
echo "[$(date)] : payload=$payload" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : payload=$payload" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
echo "[$(date)] : query_le_v2 \"$url\" \"$payload\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : query_le_v2 \"$url\" \"$payload\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
answer=$(query_le_v2 "$url" "$payload" "$nonce")
|
answer=$(query_le_v2 "$url" "$payload" "$nonce")
|
||||||
|
@ -162,10 +173,19 @@ order=$(echo -e "$answer" | grep -i location | cut -f2 -d \ | tr -d '\r\n')
|
||||||
echo "[$(date)] : order=$order" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : order=$order" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
status=$(echo "$answer" |grep HTTP/ |tail -n1 |cut -f2 -d ' ')
|
status=$(echo "$answer" |grep HTTP/ |tail -n1 |cut -f2 -d ' ')
|
||||||
echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
|
validation=$(echo "$answer" | grep 'status":' | cut -f4 -d '"')
|
||||||
|
echo "[$(date)] : validation=$validation" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
if [[ "$status" -ne 201 ]]; then
|
if [[ "$status" -ne 201 ]]; then
|
||||||
echo "[$(date)] : EXIT=Let's Encrypt new auth status $status" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : EXIT=Let's Encrypt new auth status $status" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
check_result $E_CONNECT "Let's Encrypt new auth status $status"
|
check_result $E_CONNECT "Let's Encrypt new auth status $status"
|
||||||
fi
|
fi
|
||||||
|
# # Exit the loop after 5 attempts
|
||||||
|
# i=$((i + 1))
|
||||||
|
# if [ $i -gt 5 ]; then
|
||||||
|
# break
|
||||||
|
# fi
|
||||||
|
# sleep 2
|
||||||
|
# done
|
||||||
|
|
||||||
# Requesting authorization token / STEP 3
|
# Requesting authorization token / STEP 3
|
||||||
echo "[$(date)] : --- Requesting authorization token / STEP 3 ---" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : --- Requesting authorization token / STEP 3 ---" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
|
@ -270,19 +290,35 @@ for auth in $authz; do
|
||||||
# Doing pol check on status
|
# Doing pol check on status
|
||||||
i=1
|
i=1
|
||||||
while [ "$validation" = 'pending' ]; do
|
while [ "$validation" = 'pending' ]; do
|
||||||
echo "[$(date)] : - Doing pol check on status" >> /usr/local/vesta/log/letsencrypt.log
|
i=0
|
||||||
payload='{}'
|
while true; do
|
||||||
echo "[$(date)] : query_le_v2 \"$url\" \"$payload\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : ----------------------- Doing pol check on status, counter \$i=$i -----------------------" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
answer=$(query_le_v2 "$url" "$payload" "$nonce")
|
payload='{}'
|
||||||
echo "[$(date)] : answer=$answer" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : query_le_v2 \"$url\" \"$payload\" \"$nonce\"" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
url2=$(echo "$answer" |grep -A3 $proto |grep url |cut -f 4 -d \")
|
answer=$(query_le_v2 "$url" "$payload" "$nonce")
|
||||||
echo "[$(date)] : url2=$url2" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : answer=$answer" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
validation=$(echo "$answer"|grep -A1 $proto |tail -n1|cut -f4 -d \")
|
url2=$(echo "$answer" |grep -A3 $proto |grep url |cut -f 4 -d \")
|
||||||
echo "[$(date)] : validation=$validation" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : url2=$url2" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n')
|
validation=$(echo "$answer"|grep -A1 $proto |tail -n1|cut -f4 -d \")
|
||||||
echo "[$(date)] : nonce=$nonce" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : validation=$validation" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ')
|
nonce=$(echo "$answer" |grep -i nonce |cut -f2 -d \ |tr -d '\r\n')
|
||||||
echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : nonce=$nonce" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
|
status=$(echo "$answer"|grep HTTP/ |tail -n1 |cut -f 2 -d ' ')
|
||||||
|
echo "[$(date)] : status=$status" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
|
if [[ $(echo "$answer" | grep 'addressesResolved') != "" ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
if [ "$wildcard" = 'yes' ]; then
|
||||||
|
if [[ $(echo "$answer" | grep '"status": "valid"') != "" ]]; then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
i=$((i + 1))
|
||||||
|
if ((i > 30)); then
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
if [[ "$status" -ne 200 ]]; then
|
if [[ "$status" -ne 200 ]]; then
|
||||||
echo "[$(date)] : EXIT=Let's Encrypt validation status $status" >> /usr/local/vesta/log/letsencrypt.log
|
echo "[$(date)] : EXIT=Let's Encrypt validation status $status" >> /usr/local/vesta/log/letsencrypt.log
|
||||||
check_result $E_CONNECT "Let's Encrypt validation status $status"
|
check_result $E_CONNECT "Let's Encrypt validation status $status"
|
||||||
|
|
77
bin/v-add-srs-support-to-exim
Normal file
77
bin/v-add-srs-support-to-exim
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
gen_pass() {
|
||||||
|
MATRIX='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
|
||||||
|
if [ -z "$1" ]; then
|
||||||
|
LENGTH=32
|
||||||
|
else
|
||||||
|
LENGTH=$1
|
||||||
|
fi
|
||||||
|
while [ ${n:=1} -le $LENGTH ]; do
|
||||||
|
PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
|
||||||
|
let n+=1
|
||||||
|
done
|
||||||
|
echo "$PASS"
|
||||||
|
}
|
||||||
|
|
||||||
|
eximversion=$(exim4 --version | grep '^Exim version ' | awk '{print $3}')
|
||||||
|
if (( $(echo "$eximversion < 4.96" | bc -l) )); then
|
||||||
|
echo "= ERROR: Exim SRS support requires Exim 4.96 or higher."
|
||||||
|
echo "You have Exim $eximversion"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "=== Addind SRS support to Exim4 ==="
|
||||||
|
# SRS support is taken from HestiaCP
|
||||||
|
|
||||||
|
if [ ! -f "/etc/exim4/srs.conf" ]; then
|
||||||
|
echo "= Generating SRS KEY"
|
||||||
|
srs=$(gen_pass 16)
|
||||||
|
echo $srs > /etc/exim4/srs.conf
|
||||||
|
chmod 640 /etc/exim4/srs.conf
|
||||||
|
chown root:Debian-exim /etc/exim4/srs.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "/etc/exim4/exim4.conf.template.backup-without-srs" ]; then
|
||||||
|
echo "= Backing up /etc/exim4/exim4.conf.template"
|
||||||
|
cp /etc/exim4/exim4.conf.template /etc/exim4/exim4.conf.template.backup-without-srs
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! /usr/local/vesta/bin/v-grep 'SRS_SECRET = ' '/etc/exim4/exim4.conf.template' '-q'; then
|
||||||
|
echo "= Adding: SRS_SECRET = readfile /etc/exim4/srs.conf"
|
||||||
|
v-sed 'smtputf8_advertise_hosts =' 'smtputf8_advertise_hosts =\n\nSRS_SECRET = ${readfile{/etc/exim4/srs.conf}}' '/etc/exim4/exim4.conf.template'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! /usr/local/vesta/bin/v-grep 'if outbound, and forwarding has been done, use an alternate transport' '/etc/exim4/exim4.conf.template' '-q'; then
|
||||||
|
echo "= Patching \"dnslookup:\" block"
|
||||||
|
/usr/local/vesta/bin/v-php-func "replace_in_file_once_between_including_borders" "/etc/exim4/exim4.conf.template" 'dnslookup:' ' no_more' 'dnslookup:\n driver = dnslookup\n # if outbound, and forwarding has been done, use an alternate transport\n domains = ! +local_domains\n transport = ${if eq {$local_part@$domain} \\n {$original_local_part@$original_domain} \\n {remote_smtp} {remote_forwarded_smtp}}\n no_more'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! /usr/local/vesta/bin/v-grep 'inbound_srs:' '/etc/exim4/exim4.conf.template' '-q'; then
|
||||||
|
echo "= Adding \"inbound_srs\" and \"inbound_srs_failure\" blocks"
|
||||||
|
v-sed 'aliases:' 'inbound_srs:\n driver = redirect\n senders = :\n domains = +local_domains\n # detect inbound bounces which are converted to SRS, and decode them\n condition = ${if inbound_srs {$local_part} {SRS_SECRET}}\n data = $srs_recipient\n\ninbound_srs_failure:\n driver = redirect\n senders = :\n domains = +local_domains\n # detect inbound bounces which look converted to SRS but are invalid\n condition = ${if inbound_srs {$local_part} {}}\n allow_fail\n data = :fail: Invalid SRS recipient address\n\naliases:' '/etc/exim4/exim4.conf.template'
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! /usr/local/vesta/bin/v-grep 'remote_forwarded_smtp:' '/etc/exim4/exim4.conf.template' '-q'; then
|
||||||
|
echo "= Adding \"remote_forwarded_smtp:\" block"
|
||||||
|
v-sed 'procmail:\n driver = pipe' 'remote_forwarded_smtp:\n driver = smtp\n dkim_domain = DKIM_DOMAIN\n dkim_selector = mail\n dkim_private_key = DKIM_PRIVATE_KEY\n dkim_canon = relaxed\n dkim_strict = 0\n hosts_try_fastopen = \n hosts_try_chunking = !93.188.3.0/24\n message_linelength_limit = 1G\n # modify the envelope from, for mails that we forward\n max_rcpt = 1\n return_path = ${srs_encode {SRS_SECRET} {$return_path} {$original_domain}}\n\nprocmail:\n driver = pipe' '/etc/exim4/exim4.conf.template'
|
||||||
|
fi
|
||||||
|
|
||||||
|
touch /etc/exim4/limit_per_email_account_max_sent_emails_per_hour
|
||||||
|
touch /etc/exim4/limit_per_email_account_max_recipients
|
||||||
|
touch /etc/exim4/limit_per_hosting_account_max_sent_emails_per_hour
|
||||||
|
touch /etc/exim4/limit_per_hosting_account_max_recipients
|
||||||
|
|
||||||
|
echo "= Restarting exim4 service"
|
||||||
|
systemctl restart exim4
|
||||||
|
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
systemctl status exim4
|
||||||
|
cp /etc/exim4/exim4.conf.template.backup-without-srs /etc/exim4/exim4.conf.template
|
||||||
|
systemctl restart exim4
|
||||||
|
echo "=== Patching failed, old exim conf returned, exim4 restarted again."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
echo "=== SRS support was added successfully. ==="
|
||||||
|
|
||||||
|
exit 0
|
|
@ -28,7 +28,7 @@ is_package_new() {
|
||||||
}
|
}
|
||||||
|
|
||||||
is_package_consistent() {
|
is_package_consistent() {
|
||||||
source $pkg_dir/$package.pkg
|
parse_object_kv_list_non_eval $(cat $pkg_dir/$package.pkg)
|
||||||
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
|
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
|
||||||
is_int_format_valid $WEB_DOMAINS 'WEB_DOMAINS'
|
is_int_format_valid $WEB_DOMAINS 'WEB_DOMAINS'
|
||||||
fi
|
fi
|
||||||
|
@ -63,6 +63,9 @@ is_package_consistent() {
|
||||||
is_int_format_valid $BACKUPS 'BACKUPS'
|
is_int_format_valid $BACKUPS 'BACKUPS'
|
||||||
fi
|
fi
|
||||||
is_format_valid_shell $SHELL
|
is_format_valid_shell $SHELL
|
||||||
|
is_web_template_valid $WEB_TEMPLATE
|
||||||
|
is_dns_template_valid $DNS_TEMPLATE
|
||||||
|
is_proxy_template_valid $PROXY_TEMPLATE
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
81
bin/v-add-wordpress-admin
Normal file
81
bin/v-add-wordpress-admin
Normal file
|
@ -0,0 +1,81 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Add a WordPress admin user to a specific domain
|
||||||
|
# options: DOMAIN USERNAME PASSWORD EMAIL
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
SILENT_MODE=1
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
domain=$1
|
||||||
|
username=$2
|
||||||
|
password=$3
|
||||||
|
email=$4
|
||||||
|
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
USER=$user
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
source /usr/local/vesta/func/domain.sh
|
||||||
|
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
check_result $E_NOTEXIST "domain $domain doesn't exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '4' "$#" 'DOMAIN USERNAME PASSWORD EMAIL'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user" ]; then
|
||||||
|
echo "User doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
|
||||||
|
echo "Domain doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
|
||||||
|
echo 'Please install WordPress first.'
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v wp &> /dev/null; then
|
||||||
|
echo "WP CLI is not installed. Installing..."
|
||||||
|
wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
|
||||||
|
chmod +x /usr/local/bin/wp
|
||||||
|
echo "WP CLI installed successfully."
|
||||||
|
fi
|
||||||
|
|
||||||
|
phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
cd /home/$USER/web/$domain/public_html
|
||||||
|
sudo -u $USER /usr/bin/php$phpver /usr/local/bin/wp user create $username $email --role=administrator --user_pass="$password" --skip-plugins=$(sudo -H -u$USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit 0;
|
|
@ -22,6 +22,9 @@ source $VESTA/func/domain.sh
|
||||||
source $VESTA/func/db.sh
|
source $VESTA/func/db.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
if [ ! -z "$NOW" ]; then
|
||||||
|
BACKUP_LA_LIMIT=50
|
||||||
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Verifications #
|
# Verifications #
|
||||||
|
|
6
bin/v-backup-user-now
Normal file
6
bin/v-backup-user-now
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
export ALLOW_BACKUP_ANYTIME='yes'
|
||||||
|
export NOW='yes'
|
||||||
|
|
||||||
|
nice -n 19 ionice -c 3 /usr/local/vesta/bin/v-backup-user $1
|
|
@ -37,7 +37,7 @@ fi
|
||||||
|
|
||||||
log=$VESTA/log/backup.log
|
log=$VESTA/log/backup.log
|
||||||
|
|
||||||
$BIN/v-check-vesta-license >/dev/null
|
# $BIN/v-check-vesta-license >/dev/null
|
||||||
|
|
||||||
touch $log
|
touch $log
|
||||||
if [ ! -z "$NOTIFY_ADMIN_FULL_BACKUP" ]; then
|
if [ ! -z "$NOTIFY_ADMIN_FULL_BACKUP" ]; then
|
||||||
|
|
102
bin/v-blacklist-email-account
Normal file
102
bin/v-blacklist-email-account
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Add a specific email address to exim4 and spamassassin blacklist
|
||||||
|
# usage: v-blacklist-email-account EMAIL
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Determine Debian version and set SpamAssassin service name
|
||||||
|
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
|
if [ "$release" -lt 12 ]; then
|
||||||
|
SPAMD_SERVICE="spamassassin.service"
|
||||||
|
else
|
||||||
|
SPAMD_SERVICE="spamd.service"
|
||||||
|
fi
|
||||||
|
|
||||||
|
DENY_SENDERS_FILE="/etc/exim4/deny_senders"
|
||||||
|
SPAMASSASSIN_FILE="/etc/spamassassin/local.cf"
|
||||||
|
|
||||||
|
# Flags to track changes
|
||||||
|
SPAMASSASSIN_CHANGED=false
|
||||||
|
|
||||||
|
# Function to check if an entry already exists in a file
|
||||||
|
check_entry_exists() {
|
||||||
|
local entry=$1
|
||||||
|
local file=$2
|
||||||
|
grep -qF "$entry" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add an entry to a file
|
||||||
|
add_entry_to_file() {
|
||||||
|
local entry=$1
|
||||||
|
local file=$2
|
||||||
|
echo "$entry" >> "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display usage if no arguments are provided
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Usage: v-blacklist-email EMAIL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
EMAIL=$1
|
||||||
|
|
||||||
|
# Validate email format
|
||||||
|
if [[ ! "$EMAIL" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then
|
||||||
|
echo "Invalid email address format."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prepare entries for Exim4 and SpamAssassin
|
||||||
|
EXIM_ENTRY="$EMAIL"
|
||||||
|
SPAMASSASSIN_ENTRY="blacklist_from $EMAIL"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Exim4 Blacklist #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
echo "Updating $DENY_SENDERS_FILE..."
|
||||||
|
if ! check_entry_exists "$EXIM_ENTRY" "$DENY_SENDERS_FILE"; then
|
||||||
|
add_entry_to_file "$EXIM_ENTRY" "$DENY_SENDERS_FILE"
|
||||||
|
echo "Added $EXIM_ENTRY to $DENY_SENDERS_FILE."
|
||||||
|
else
|
||||||
|
echo "$EXIM_ENTRY already exists in $DENY_SENDERS_FILE."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# SpamAssassin Blacklist #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
echo "Updating $SPAMASSASSIN_FILE..."
|
||||||
|
if ! check_entry_exists "$SPAMASSASSIN_ENTRY" "$SPAMASSASSIN_FILE"; then
|
||||||
|
add_entry_to_file "$SPAMASSASSIN_ENTRY" "$SPAMASSASSIN_FILE"
|
||||||
|
echo "Added $SPAMASSASSIN_ENTRY to $SPAMASSASSIN_FILE."
|
||||||
|
SPAMASSASSIN_CHANGED=true
|
||||||
|
else
|
||||||
|
echo "$SPAMASSASSIN_ENTRY already exists in $SPAMASSASSIN_FILE."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SPAMASSASSIN_CHANGED" == "true" ]; then
|
||||||
|
systemctl restart "$SPAMD_SERVICE"
|
||||||
|
echo "SpamAssassin service ($SPAMD_SERVICE) restarted."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Done #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit 0
|
133
bin/v-blacklist-email-domain
Normal file
133
bin/v-blacklist-email-domain
Normal file
|
@ -0,0 +1,133 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Add a domain to exim4 and spamassassin blacklist
|
||||||
|
# usage: v-blacklist-email-domain DOMAIN SUBDOMAIN(YES/NO)
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Determine Debian version and set SpamAssassin service name
|
||||||
|
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
|
if [ "$release" -lt 12 ]; then
|
||||||
|
SPAMD_SERVICE="spamassassin.service"
|
||||||
|
else
|
||||||
|
SPAMD_SERVICE="spamd.service"
|
||||||
|
fi
|
||||||
|
|
||||||
|
DENY_SENDERS_FILE="/etc/exim4/deny_senders"
|
||||||
|
SPAMASSASSIN_FILE="/etc/spamassassin/local.cf"
|
||||||
|
|
||||||
|
# Flags to track changes
|
||||||
|
SPAMASSASSIN_CHANGED=false
|
||||||
|
|
||||||
|
# Function to check if a domain already exists in a file
|
||||||
|
check_domain_exists() {
|
||||||
|
local domain=$1
|
||||||
|
local file=$2
|
||||||
|
grep -qE "^${domain}$" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to check if a SpamAssassin entry already exists
|
||||||
|
check_spamassassin_exists() {
|
||||||
|
local entry=$1
|
||||||
|
local file=$2
|
||||||
|
grep -qF "$entry" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add domain to file
|
||||||
|
add_domain_to_file() {
|
||||||
|
local domain=$1
|
||||||
|
local file=$2
|
||||||
|
echo "$domain" >> "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display usage if no arguments are provided
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo "Usage: v-blacklist-domain DOMAIN SUBDOMAIN(YES/NO)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
DOMAIN=$1
|
||||||
|
SUBDOMAIN=${2^^} # Convert to uppercase for consistency (YES/NO)
|
||||||
|
|
||||||
|
# Validate SUBDOMAIN parameter
|
||||||
|
if [[ "$SUBDOMAIN" != "YES" && "$SUBDOMAIN" != "NO" ]]; then
|
||||||
|
echo "Invalid parameter for SUBDOMAIN. Use YES or NO."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prepare entries for Exim4
|
||||||
|
EXIM_ENTRY_MAIN="$DOMAIN"
|
||||||
|
EXIM_ENTRY_SUB="*.$DOMAIN"
|
||||||
|
|
||||||
|
# Prepare entries for SpamAssassin
|
||||||
|
SPAMASSASSIN_ENTRY_MAIN="blacklist_from *@${DOMAIN}"
|
||||||
|
SPAMASSASSIN_ENTRY_SUB="blacklist_from *.$DOMAIN"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Exim4 Blacklist #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
echo "Updating $DENY_SENDERS_FILE..."
|
||||||
|
if ! check_domain_exists "$EXIM_ENTRY_MAIN" "$DENY_SENDERS_FILE"; then
|
||||||
|
add_domain_to_file "$EXIM_ENTRY_MAIN" "$DENY_SENDERS_FILE"
|
||||||
|
echo "Added $EXIM_ENTRY_MAIN to $DENY_SENDERS_FILE."
|
||||||
|
else
|
||||||
|
echo "$EXIM_ENTRY_MAIN already exists in $DENY_SENDERS_FILE."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SUBDOMAIN" == "YES" ]; then
|
||||||
|
if ! check_domain_exists "$EXIM_ENTRY_SUB" "$DENY_SENDERS_FILE"; then
|
||||||
|
add_domain_to_file "$EXIM_ENTRY_SUB" "$DENY_SENDERS_FILE"
|
||||||
|
echo "Added $EXIM_ENTRY_SUB to $DENY_SENDERS_FILE."
|
||||||
|
else
|
||||||
|
echo "$EXIM_ENTRY_SUB already exists in $DENY_SENDERS_FILE."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# SpamAssassin Blacklist #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
echo "Updating $SPAMASSASSIN_FILE..."
|
||||||
|
if ! check_spamassassin_exists "$SPAMASSASSIN_ENTRY_MAIN" "$SPAMASSASSIN_FILE"; then
|
||||||
|
add_domain_to_file "$SPAMASSASSIN_ENTRY_MAIN" "$SPAMASSASSIN_FILE"
|
||||||
|
echo "Added $SPAMASSASSIN_ENTRY_MAIN to $SPAMASSASSIN_FILE."
|
||||||
|
SPAMASSASSIN_CHANGED=true
|
||||||
|
else
|
||||||
|
echo "$SPAMASSASSIN_ENTRY_MAIN already exists in $SPAMASSASSIN_FILE."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SUBDOMAIN" == "YES" ]; then
|
||||||
|
if ! check_spamassassin_exists "$SPAMASSASSIN_ENTRY_SUB" "$SPAMASSASSIN_FILE"; then
|
||||||
|
add_domain_to_file "$SPAMASSASSIN_ENTRY_SUB" "$SPAMASSASSIN_FILE"
|
||||||
|
echo "Added $SPAMASSASSIN_ENTRY_SUB to $SPAMASSASSIN_FILE."
|
||||||
|
SPAMASSASSIN_CHANGED=true
|
||||||
|
else
|
||||||
|
echo "$SPAMASSASSIN_ENTRY_SUB already exists in $SPAMASSASSIN_FILE."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$SPAMASSASSIN_CHANGED" == "true" ]; then
|
||||||
|
systemctl restart "$SPAMD_SERVICE"
|
||||||
|
echo "SpamAssassin service ($SPAMD_SERVICE) restarted."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Done #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit 0
|
63
bin/v-change-database-password-for-all-wordpress
Normal file
63
bin/v-change-database-password-for-all-wordpress
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: change db password to all wordpress databases
|
||||||
|
# options:
|
||||||
|
#
|
||||||
|
# The command is used for changing db password to all wordpress databases on the server.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Importing system variables
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
only_user='';
|
||||||
|
if [ ! -z "$1" ]; then
|
||||||
|
only_user=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
touch /root/remember-db-user-pass.txt
|
||||||
|
|
||||||
|
for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
|
||||||
|
if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -z "$only_user" ]; then
|
||||||
|
if [ "$only_user" != "$user" ]; then
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
|
||||||
|
if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
|
||||||
|
/usr/local/vesta/bin/v-change-database-password-for-wordpress $domain $user
|
||||||
|
echo "--------------------------------"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ! -z "$only_user" ]; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
# cat /root/remember-db-user-pass.txt
|
||||||
|
rm /root/remember-db-user-pass.txt
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
|
exit
|
123
bin/v-change-database-password-for-wordpress
Normal file
123
bin/v-change-database-password-for-wordpress
Normal file
|
@ -0,0 +1,123 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: change database password for wordpress
|
||||||
|
# options:
|
||||||
|
#
|
||||||
|
# The command is used for changing database password for wordpress.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
domain=$1
|
||||||
|
|
||||||
|
# Check if number of arguments is 2
|
||||||
|
if [ $# -eq 2 ]; then
|
||||||
|
user=$2
|
||||||
|
else
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
fi
|
||||||
|
USER=$user
|
||||||
|
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
echo "ERROR: Domain $domain not found"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user" ]; then
|
||||||
|
echo "ERROR: User $user doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'DOMAIN'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
|
||||||
|
echo "ERROR: Domain doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [ -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
|
||||||
|
echo "=== Domain: $domain"
|
||||||
|
wp_config_path="/home/$user/web/$domain/public_html/wp-config.php"
|
||||||
|
if grep -q $'\r' $wp_config_path; then
|
||||||
|
echo "=== removing CRLF from wp-config.php"
|
||||||
|
tr -d '\r' < $wp_config_path > /tmp/wp-config.php && mv /tmp/wp-config.php $wp_config_path
|
||||||
|
chown $user:$user $wp_config_path
|
||||||
|
fi
|
||||||
|
db_name=$(grep "DB_NAME" $wp_config_path | grep -oP "define\s*\(\s*'DB_NAME'\s*,\s*'\K[^']+")
|
||||||
|
db_user=$(grep "DB_USER" $wp_config_path | grep -oP "define\s*\(\s*'DB_USER'\s*,\s*'\K[^']+")
|
||||||
|
new_password=''
|
||||||
|
found_existing_password=0
|
||||||
|
if [ -f "/root/remember-db-user-pass.txt" ]; then
|
||||||
|
db_user_pass=$(grep "$db_user:" /root/remember-db-user-pass.txt)
|
||||||
|
if [ -n "$db_user_pass" ]; then
|
||||||
|
new_password=$(echo "$db_user_pass" | cut -d':' -f2)
|
||||||
|
echo "= Using existing password for $db_user"
|
||||||
|
found_existing_password=1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$new_password" ]; then
|
||||||
|
new_password=$(generate_password)
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "DB name: $db_name"
|
||||||
|
echo "DB user: $db_user"
|
||||||
|
echo "New DB password: $new_password"
|
||||||
|
if [ $found_existing_password -eq 0 ] && [ -f "/root/remember-db-user-pass.txt" ]; then
|
||||||
|
echo "$db_user:$new_password" >> /root/remember-db-user-pass.txt
|
||||||
|
fi
|
||||||
|
/usr/local/vesta/bin/v-change-database-password "$user" "$db_name" "$new_password"
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "*************** ERROR: Failed to change database password ***************"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
line="define('DB_PASSWORD', '$new_password');"
|
||||||
|
chattr -i $wp_config_path
|
||||||
|
sed -i "s/.*define(.*DB_PASSWORD'.*/$line/" $wp_config_path
|
||||||
|
new_password_line=$(grep "DB_PASSWORD" $wp_config_path)
|
||||||
|
echo "New DB password line: $new_password_line"
|
||||||
|
if [ "$new_password_line" != "$line" ]; then
|
||||||
|
echo "*************** ERROR: line in wp-config.php is not what we expected ***************"
|
||||||
|
echo "Expected: $line"
|
||||||
|
echo "Actual : $new_password_line"
|
||||||
|
echo "*************** ERROR: Please check wp-config.php manually ***************"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "ERROR: WP-config.php not found"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
|
exit
|
71
bin/v-change-dir-www
Normal file
71
bin/v-change-dir-www
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Change directory to the public_html folder of a domain
|
||||||
|
# usage: source v-cd-www DOMAIN
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
||||||
|
echo "This script must be sourced to change the current directory."
|
||||||
|
echo "Usage: source v-cd-www DOMAIN"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
PATH=$PATH:/usr/local/vesta/bin && export PATH
|
||||||
|
|
||||||
|
SILENT_MODE=1
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
domain=$1
|
||||||
|
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
echo "Domain $domain doesn't exist"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
USER=$user
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
source /usr/local/vesta/func/domain.sh
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'DOMAIN'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user" ]; then
|
||||||
|
echo "User $user doesn't exist"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
|
||||||
|
echo "Domain $domain doesn't have a public_html directory"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
cd "/home/$user/web/$domain/public_html"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
return 0
|
|
@ -35,6 +35,9 @@ if [ "$owner" = "$user" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
USER_DATA=$VESTA/data/users/$owner
|
||||||
|
is_object_unsuspended 'user' 'USER' "$owner"
|
||||||
|
USER_DATA=$VESTA/data/users/$user
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
|
@ -57,11 +60,11 @@ if [ ! -z "$web_data" ]; then
|
||||||
ssl_key=$VESTA/data/users/$owner/ssl/$domain.key
|
ssl_key=$VESTA/data/users/$owner/ssl/$domain.key
|
||||||
ssl_ca=$VESTA/data/users/$owner/ssl/$domain.ca
|
ssl_ca=$VESTA/data/users/$owner/ssl/$domain.ca
|
||||||
ssl_pem=$VESTA/data/users/$owner/ssl/$domain.pem
|
ssl_pem=$VESTA/data/users/$owner/ssl/$domain.pem
|
||||||
mv $ssl_crt $VESTA/data/users/$user/ssl/
|
cp $ssl_crt $VESTA/data/users/$user/ssl/
|
||||||
mv $ssl_key $VESTA/data/users/$user/ssl/
|
cp $ssl_key $VESTA/data/users/$user/ssl/
|
||||||
mv $ssl_ca $VESTA/data/users/$user/ssl/ >> /dev/null 2>&1
|
cp $ssl_ca $VESTA/data/users/$user/ssl/ > /dev/null 2>&1
|
||||||
mv $ssl_pem $VESTA/data/users/$user/ssl/ >> /dev/null 2>&1
|
cp $ssl_pem $VESTA/data/users/$user/ssl/ > /dev/null 2>&1
|
||||||
rm -f $HOMEDIR/$owner/conf/web/ssl.$domain.*
|
# rm -f $HOMEDIR/$owner/conf/web/ssl.$domain.*
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check ftp user account
|
# Check ftp user account
|
||||||
|
@ -79,10 +82,23 @@ if [ ! -z "$web_data" ]; then
|
||||||
# Move data
|
# Move data
|
||||||
mv $HOMEDIR/$owner/web/$domain $HOMEDIR/$user/web/
|
mv $HOMEDIR/$owner/web/$domain $HOMEDIR/$user/web/
|
||||||
|
|
||||||
|
if [ -d "/hdd/home/$owner/web/$domain" ]; then
|
||||||
|
$BIN/v-move-folder-and-make-symlink /hdd/home/$owner/web/$domain /hdd/home/$user/web/$domain
|
||||||
|
fi
|
||||||
|
|
||||||
# Change ownership
|
# Change ownership
|
||||||
find $HOMEDIR/$user/web/$domain -user $owner \
|
find $HOMEDIR/$user/web/$domain -user $owner \
|
||||||
-exec chown -h $user:$user {} \;
|
-exec chown -h $user:$user {} \;
|
||||||
|
|
||||||
|
if [ "$SSL" = 'yes' ]; then
|
||||||
|
sleep 10
|
||||||
|
rm $ssl_crt
|
||||||
|
rm $ssl_key
|
||||||
|
rm $ssl_ca > /dev/null 2>&1
|
||||||
|
rm $ssl_pem > /dev/null 2>&1
|
||||||
|
rm -f $HOMEDIR/$owner/conf/web/ssl.$domain.*
|
||||||
|
fi
|
||||||
|
|
||||||
# Rebuild config
|
# Rebuild config
|
||||||
$BIN/v-unsuspend-web-domain $user $domain no >> /dev/null 2>&1
|
$BIN/v-unsuspend-web-domain $user $domain no >> /dev/null 2>&1
|
||||||
$BIN/v-rebuild-web-domains $owner no
|
$BIN/v-rebuild-web-domains $owner no
|
||||||
|
@ -140,6 +156,10 @@ if [ ! -z "$mail_data" ]; then
|
||||||
# Move data
|
# Move data
|
||||||
mv $HOMEDIR/$owner/mail/$domain $HOMEDIR/$user/mail/
|
mv $HOMEDIR/$owner/mail/$domain $HOMEDIR/$user/mail/
|
||||||
|
|
||||||
|
if [ -d "/hdd/home/$owner/mail/$domain" ]; then
|
||||||
|
$BIN/v-move-folder-and-make-symlink /hdd/home/$owner/mail/$domain /hdd/home/$user/mail/$domain
|
||||||
|
fi
|
||||||
|
|
||||||
# Change ownership
|
# Change ownership
|
||||||
find $HOMEDIR/$user/mail/$domain -user $owner \
|
find $HOMEDIR/$user/mail/$domain -user $owner \
|
||||||
-exec chown -h $user {} \;
|
-exec chown -h $user {} \;
|
||||||
|
|
|
@ -62,6 +62,8 @@ str="RULE='$rule' ACTION='$action' PROTOCOL='$protocol' PORT='$port_ext'"
|
||||||
str="$str IP='$ip' COMMENT='$comment' SUSPENDED='no'"
|
str="$str IP='$ip' COMMENT='$comment' SUSPENDED='no'"
|
||||||
str="$str TIME='$time' DATE='$date'"
|
str="$str TIME='$time' DATE='$date'"
|
||||||
|
|
||||||
|
oldvalues=$(grep "RULE='$rule'" $VESTA/data/firewall/rules.conf)
|
||||||
|
|
||||||
# Deleting old rule
|
# Deleting old rule
|
||||||
sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf
|
sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf
|
||||||
|
|
||||||
|
@ -74,6 +76,14 @@ sort_fw_rules
|
||||||
# Updating system firewall
|
# Updating system firewall
|
||||||
$BIN/v-update-firewall
|
$BIN/v-update-firewall
|
||||||
|
|
||||||
|
if [ "$WEB_SYSTEM" == 'nginx' ] || [ "$PROXY_SYSTEM" == 'nginx' ]; then
|
||||||
|
if [ "$port_ext" == "80,443" ] && [ "$action" == "DROP" ]; then
|
||||||
|
NEWIP=$ip
|
||||||
|
parse_object_kv_list_non_eval "$oldvalues"
|
||||||
|
sed -i "s|$IP|$NEWIP|g" /etc/nginx/conf.d/block-firewall.conf
|
||||||
|
systemctl restart nginx
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
|
|
|
@ -16,6 +16,7 @@ force=$3
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/func/domain.sh
|
||||||
source $VESTA/conf/vesta.conf
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
is_package_avalable() {
|
is_package_avalable() {
|
||||||
|
@ -23,7 +24,7 @@ is_package_avalable() {
|
||||||
usr_data=$(cat $USER_DATA/user.conf)
|
usr_data=$(cat $USER_DATA/user.conf)
|
||||||
IFS=$'\n'
|
IFS=$'\n'
|
||||||
for key in $usr_data; do
|
for key in $usr_data; do
|
||||||
eval ${key%%=*}=${key#*=}
|
parse_object_kv_list_non_eval $key
|
||||||
done
|
done
|
||||||
|
|
||||||
WEB_DOMAINS='0'
|
WEB_DOMAINS='0'
|
||||||
|
@ -35,7 +36,7 @@ is_package_avalable() {
|
||||||
|
|
||||||
pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\
|
pkg_data=$(cat $VESTA/data/packages/$package.pkg |grep -v TIME |\
|
||||||
grep -v DATE)
|
grep -v DATE)
|
||||||
eval $pkg_data
|
parse_object_kv_list_non_eval $pkg_data
|
||||||
|
|
||||||
# Checking usage agains package limits
|
# Checking usage agains package limits
|
||||||
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
|
if [ "$WEB_DOMAINS" != 'unlimited' ]; then
|
||||||
|
@ -73,11 +74,15 @@ is_package_avalable() {
|
||||||
check_result $E_LIMIT "Package doesn't cover BANDWIDTH usage"
|
check_result $E_LIMIT "Package doesn't cover BANDWIDTH usage"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
is_web_template_valid $WEB_TEMPLATE
|
||||||
|
is_dns_template_valid $DNS_TEMPLATE
|
||||||
|
is_proxy_template_valid $PROXY_TEMPLATE
|
||||||
}
|
}
|
||||||
|
|
||||||
change_user_package() {
|
change_user_package() {
|
||||||
eval $(cat $USER_DATA/user.conf)
|
parse_object_kv_list_non_eval $(cat $USER_DATA/user.conf)
|
||||||
eval $(cat $VESTA/data/packages/$package.pkg |egrep -v "TIME|DATE")
|
parse_object_kv_list_non_eval $(cat $VESTA/data/packages/$package.pkg |egrep -v "TIME|DATE")
|
||||||
echo "FNAME='$FNAME'
|
echo "FNAME='$FNAME'
|
||||||
LNAME='$LNAME'
|
LNAME='$LNAME'
|
||||||
PACKAGE='$package'
|
PACKAGE='$package'
|
||||||
|
|
|
@ -41,6 +41,7 @@ is_int_format_valid "$port" 'port number'
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
sed -i "s|$oldport;|$port;|g" $VESTA/nginx/conf/nginx.conf
|
sed -i "s|$oldport;|$port;|g" $VESTA/nginx/conf/nginx.conf
|
||||||
|
sed -i "s|$oldport ssl;|$port ssl;|g" $VESTA/nginx/conf/nginx.conf
|
||||||
if [ -f "/etc/roundcube/plugins/password/config.inc.php" ]; then
|
if [ -f "/etc/roundcube/plugins/password/config.inc.php" ]; then
|
||||||
sed -i "s|'$oldport'|'$port'|g" /etc/roundcube/plugins/password/config.inc.php
|
sed -i "s|'$oldport'|'$port'|g" /etc/roundcube/plugins/password/config.inc.php
|
||||||
fi
|
fi
|
||||||
|
|
160
bin/v-change-wordpress-admin-passwords
Normal file
160
bin/v-change-wordpress-admin-passwords
Normal file
|
@ -0,0 +1,160 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: interactively delete or change WordPress admin passwords for a given domain
|
||||||
|
# options: DOMAIN
|
||||||
|
#
|
||||||
|
# d → delete user (with content reassignment)
|
||||||
|
# c → change password (random 10-char alnum)
|
||||||
|
# s → skip
|
||||||
|
# x → exit
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable & Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
[ "$(whoami)" != "root" ] && { echo "You must be root to run this command."; exit 1; }
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
DOMAIN="$1"
|
||||||
|
[ -z "$DOMAIN" ] && { echo "Usage: v-change-wp-admins-pass DOMAIN"; exit 1; }
|
||||||
|
|
||||||
|
USER="$(/usr/local/vesta/bin/v-search-domain-owner "$DOMAIN")"
|
||||||
|
[ -z "$USER" ] && { echo "Domain $DOMAIN does not exist."; exit 1; }
|
||||||
|
|
||||||
|
WP_PATH="/home/$USER/web/$DOMAIN/public_html"
|
||||||
|
[ ! -f "$WP_PATH/wp-config.php" ] && { echo "WordPress is not installed on this domain."; exit 1; }
|
||||||
|
|
||||||
|
# WP-CLI wrapper
|
||||||
|
WP_RUN=(/usr/local/vesta/bin/v-run-wp-cli $DOMAIN --skip-plugins --skip-themes)
|
||||||
|
return_code=$?
|
||||||
|
|
||||||
|
if [ $return_code -ne 0 ]; then
|
||||||
|
echo "WP-CLI error:"
|
||||||
|
cat /home/$USER/web/$DOMAIN/wp-cli-error.log
|
||||||
|
exit $return_code
|
||||||
|
fi
|
||||||
|
|
||||||
|
# random 10-char password
|
||||||
|
gen_pass() { tr -dc 'A-Za-z0-9' </dev/urandom | head -c 10; }
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
cd "$WP_PATH" || exit 1
|
||||||
|
echo
|
||||||
|
echo "WordPress administrators for $DOMAIN:"
|
||||||
|
echo "-------------------------------------"
|
||||||
|
|
||||||
|
if [ -f /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ]; then
|
||||||
|
rm /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
|
||||||
|
fi
|
||||||
|
|
||||||
|
ADMIN_LIST_CSV=$("${WP_RUN[@]}" user list --role=administrator \
|
||||||
|
--fields=ID,user_login,user_email \
|
||||||
|
--format=csv --skip-plugins --skip-themes 2>/dev/null | tail -n +2)
|
||||||
|
[ -z "$ADMIN_LIST_CSV" ] && { echo "No administrator accounts found."; exit 0; }
|
||||||
|
|
||||||
|
printf "%-6s %-20s %s\n" "ID" "Username" "Email"
|
||||||
|
echo "$ADMIN_LIST_CSV" | while IFS=',' read -r PID PLOGIN PEMAIL; do
|
||||||
|
printf "%-6s %-20s %s\n" "$PID" "$PLOGIN" "$PEMAIL"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "For each admin choose: (d) delete, (c) change password, (s) skip, (x) exit."
|
||||||
|
|
||||||
|
# interactive loop
|
||||||
|
while IFS=',' read -r ID LOGIN EMAIL; do
|
||||||
|
[ -n "$EMAIL" ] && TARGET="$LOGIN <$EMAIL>" || TARGET="$LOGIN"
|
||||||
|
while true; do
|
||||||
|
echo "-------------------------------------"
|
||||||
|
read -r -p "Action for \"$TARGET\" [d/c/s/x]? " ACT < /dev/tty
|
||||||
|
case "$ACT" in
|
||||||
|
[Dd]* )
|
||||||
|
# read -r -p "Really DELETE \"$TARGET\" ? (y/n, default: y) " CONF < /dev/tty
|
||||||
|
CONF="y"
|
||||||
|
if [[ ! "$CONF" =~ ^[Nn]$ ]]; then
|
||||||
|
# build an array of OTHER admin usernames
|
||||||
|
mapfile -t OTHER_USERS < <(echo "$ADMIN_LIST_CSV" | awk -F',' -v cur="$ID" '$1!=cur {print $2}')
|
||||||
|
if [ "${#OTHER_USERS[@]}" -eq 0 ]; then
|
||||||
|
echo "Cannot delete the only administrator account."
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
DEFAULT_USER="${OTHER_USERS[0]}"
|
||||||
|
echo "Available admin usernames for reassignment: ${OTHER_USERS[*]}"
|
||||||
|
while true; do
|
||||||
|
read -r -p "Reassign content to which username? [default: $DEFAULT_USER] " REASSIGN < /dev/tty
|
||||||
|
REASSIGN=${REASSIGN:-$DEFAULT_USER}
|
||||||
|
if printf '%s\n' "${OTHER_USERS[@]}" | grep -qx "$REASSIGN"; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "Invalid username. Please choose one of: ${OTHER_USERS[*]}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
# delete by username, reassign by username
|
||||||
|
"${WP_RUN[@]}" user delete "$LOGIN" --reassign="$REASSIGN" --yes --skip-plugins --skip-themes
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "$TARGET deleted (content reassigned to $REASSIGN)."
|
||||||
|
else
|
||||||
|
cat /home/$USER/web/$DOMAIN/wp-cli-error.log
|
||||||
|
echo "Failed to delete $TARGET."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "Deletion cancelled."
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
[Cc]* )
|
||||||
|
NEW_PASS=$(gen_pass)
|
||||||
|
"${WP_RUN[@]}" user update "$LOGIN" --user_pass="$NEW_PASS" --skip-plugins --skip-themes
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo "Password for username '$TARGET' changed to: $NEW_PASS"
|
||||||
|
echo "Password for username '$TARGET' changed to: $NEW_PASS" >> /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
|
||||||
|
chown $USER:$USER /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
|
||||||
|
chmod 600 /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
|
||||||
|
else
|
||||||
|
cat /home/$USER/web/$DOMAIN/wp-cli-error.log
|
||||||
|
echo "Failed to change password for $TARGET."
|
||||||
|
fi
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
[Ss]* )
|
||||||
|
echo "Skipping $TARGET."
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
[Xx]* )
|
||||||
|
echo "Exiting."
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
* ) echo "Please answer d, c, s, or x." ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
done <<< "$ADMIN_LIST_CSV"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# flush cache and refresh all security salts #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
echo "-------------------------------------"
|
||||||
|
echo
|
||||||
|
echo "Flushing cache and refreshing salts..."
|
||||||
|
|
||||||
|
"${WP_RUN[@]}" cache flush
|
||||||
|
"${WP_RUN[@]}" config shuffle-salts WP_CACHE_KEY_SALT --force
|
||||||
|
"${WP_RUN[@]}" config shuffle-salts
|
||||||
|
|
||||||
|
echo "Cache flushed and salts refreshed."
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Done."
|
||||||
|
|
||||||
|
if [ -f /home/$USER/web/$DOMAIN/wp-admin-password-change.txt ]; then
|
||||||
|
echo "-------------------------------------"
|
||||||
|
echo "For website $DOMAIN - new wp-admin passwords have been set."
|
||||||
|
echo "-------------------------------------"
|
||||||
|
cat /home/$USER/web/$DOMAIN/wp-admin-password-change.txt
|
||||||
|
echo "-------------------------------------"
|
||||||
|
echo ""
|
||||||
|
read -r -p "== Press Enter to continue..."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0
|
|
@ -14,6 +14,10 @@ if [ "$whoami" != "root" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "===== Before cleaning ====="
|
||||||
|
df -h
|
||||||
|
echo "==========================="
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source /usr/local/vesta/func/main.sh
|
source /usr/local/vesta/func/main.sh
|
||||||
|
|
||||||
|
@ -21,6 +25,15 @@ source /usr/local/vesta/func/main.sh
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# turn off tailf watcher process
|
||||||
|
if [ -f "/usr/local/bin/tailf_apache_error.php" ]; then
|
||||||
|
kill $(ps aux | grep 'tailf_apache_error' | grep -v "grep tailf_apache_error" | awk '{print $2}')
|
||||||
|
fi
|
||||||
|
if [ -f "/usr/local/bin/tailf_exim.php" ]; then
|
||||||
|
kill $(ps aux | grep 'tailf_exim' | grep -v "grep tailf_exim" | awk '{print $2}')
|
||||||
|
fi
|
||||||
|
|
||||||
|
find /tmp/ -type f -mtime +7 -delete
|
||||||
rm /var/backups/* > /dev/null 2>&1
|
rm /var/backups/* > /dev/null 2>&1
|
||||||
rm /var/cache/apt/archives/* > /dev/null 2>&1
|
rm /var/cache/apt/archives/* > /dev/null 2>&1
|
||||||
cd /var/log
|
cd /var/log
|
||||||
|
@ -37,13 +50,18 @@ find /var/log/ -type f -name "*.4" -delete
|
||||||
find /var/log/ -type f -name "*.5" -delete
|
find /var/log/ -type f -name "*.5" -delete
|
||||||
find /var/log/ -type f -name "*.6" -delete
|
find /var/log/ -type f -name "*.6" -delete
|
||||||
find /var/log/ -type f -name "*.7" -delete
|
find /var/log/ -type f -name "*.7" -delete
|
||||||
|
find /var/log/ -type f -name "*.8" -delete
|
||||||
|
find /var/log/ -type f -name "*.9" -delete
|
||||||
find /var/log/ -name "*.gz" -type f -delete
|
find /var/log/ -name "*.gz" -type f -delete
|
||||||
find /usr/local/vesta/log/ -type f -name "*.log" -exec truncate -s 0 {} \;
|
find /usr/local/vesta/log/ -type f -name "*.log" -exec truncate -s 0 {} \;
|
||||||
find /usr/local/vesta/log/ -type f -not -name "*.log" -delete
|
find /usr/local/vesta/log/ -type f -not -name "*.log" -delete
|
||||||
find /var/log/exim4/ -type f -exec truncate -s 0 {} \;
|
find /var/log/exim4/ -type f -exec truncate -s 0 {} \;
|
||||||
|
truncate -s 0 /*.log > /dev/null 2>&1
|
||||||
|
rm /panic-*.log > /dev/null 2>&1
|
||||||
|
rm /var/log/panic-*.log > /dev/null 2>&1
|
||||||
|
|
||||||
clean_home() {
|
clean_home() {
|
||||||
nice -n 19 ionice -c 3 find $1/*/tmp/ -type f -delete
|
nice -n 19 ionice -c 3 find $1/*/tmp/ -type f -delete > /dev/null 2>&1
|
||||||
find $1/ -name '.wp-cli' -type d -exec rm -rf {} \; > /dev/null 2>&1
|
find $1/ -name '.wp-cli' -type d -exec rm -rf {} \; > /dev/null 2>&1
|
||||||
find $1/*/web/*/public_html/wp-content/aiowps_backups/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
find $1/*/web/*/public_html/wp-content/aiowps_backups/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
||||||
find $1/*/web/*/public_html/wp-content/envato-backups/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
find $1/*/web/*/public_html/wp-content/envato-backups/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
||||||
|
@ -51,7 +69,10 @@ clean_home() {
|
||||||
find $1/*/web/*/public_html/wp-content/wpvividbackups/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
find $1/*/web/*/public_html/wp-content/wpvividbackups/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
||||||
find $1/*/web/*/public_html/wp-content/updraft/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
find $1/*/web/*/public_html/wp-content/updraft/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
||||||
find $1/*/web/*/public_html/wp-content/plugins/ezpz-one-click-backup/backups/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
find $1/*/web/*/public_html/wp-content/plugins/ezpz-one-click-backup/backups/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
||||||
|
find $1/*/web/*/public_html/wp-content/backups-dup-lite/ -type f -not -name ".htaccess" -not -name "index.php" -not -name "index.html" -not -name "web.config" -delete > /dev/null 2>&1
|
||||||
|
find $1/*/web/*/public_html/wp-content/cache/ -type f -not -name ".htaccess" -delete > /dev/null 2>&1
|
||||||
find $1/*/web/*/public_html/ -type f -name "*.wpress" -delete > /dev/null 2>&1
|
find $1/*/web/*/public_html/ -type f -name "*.wpress" -delete > /dev/null 2>&1
|
||||||
|
nice -n 19 ionice -c 3 find $1/*/tmp/ -type f -mtime +1 -delete > /dev/null 2>&1
|
||||||
nice -n 19 ionice -c 3 find $1/*/web/*/public_html/ -type f -name "error_log" -exec truncate -s 0 {} \;
|
nice -n 19 ionice -c 3 find $1/*/web/*/public_html/ -type f -name "error_log" -exec truncate -s 0 {} \;
|
||||||
nice -n 19 ionice -c 3 find $1/*/web/*/public_html/ -type f -name "error_log.txt" -exec truncate -s 0 {} \;
|
nice -n 19 ionice -c 3 find $1/*/web/*/public_html/ -type f -name "error_log.txt" -exec truncate -s 0 {} \;
|
||||||
nice -n 19 ionice -c 3 find $1/ -type f -name "*.log" -exec truncate -s 0 {} \;
|
nice -n 19 ionice -c 3 find $1/ -type f -name "*.log" -exec truncate -s 0 {} \;
|
||||||
|
@ -69,16 +90,43 @@ if [ $fail2ban_running -eq 1 ]; then
|
||||||
fi
|
fi
|
||||||
if [ -f "/var/lib/fail2ban/fail2ban.sqlite3" ]; then
|
if [ -f "/var/lib/fail2ban/fail2ban.sqlite3" ]; then
|
||||||
rm /var/lib/fail2ban/fail2ban.sqlite3
|
rm /var/lib/fail2ban/fail2ban.sqlite3
|
||||||
|
if [ -f "/etc/nginx/conf.d/block.conf" ]; then
|
||||||
|
truncate -s 0 /etc/nginx/conf.d/block.conf
|
||||||
|
nginx_running=$(/usr/local/vesta/bin/v-list-sys-services | grep 'nginx' | grep -c 'running')
|
||||||
|
if [ $nginx_running -eq 1 ]; then
|
||||||
|
systemctl restart nginx
|
||||||
|
fi
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ $fail2ban_running -eq 1 ]; then
|
if [ $fail2ban_running -eq 1 ]; then
|
||||||
systemctl start fail2ban
|
systemctl start fail2ban
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# turn on tailf watcher process
|
||||||
|
if [ -f "/usr/local/bin/tailf_apache_error.php" ]; then
|
||||||
|
nohup php /usr/local/bin/tailf_apache_error.php > /var/log/tailf_apache_error.log 2>&1 &
|
||||||
|
fi
|
||||||
|
if [ -f "/usr/local/bin/tailf_exim.php" ]; then
|
||||||
|
nohup php /usr/local/bin/tailf_exim.php > /var/log/tailf_exim.log 2>&1 &
|
||||||
|
fi
|
||||||
|
|
||||||
|
exim_installed=$(/usr/local/vesta/bin/v-list-sys-services | grep -c 'exim')
|
||||||
|
if [ $exim_installed -gt 0 ]; then
|
||||||
|
systemctl restart exim4
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
echo "=== Garbage cleaned ==="
|
echo ""
|
||||||
|
echo "***** Garbage cleaned *****"
|
||||||
|
echo ""
|
||||||
|
echo "===== After cleaning ======"
|
||||||
|
df -h
|
||||||
|
echo "==========================="
|
||||||
|
|
||||||
|
|
||||||
log_event "$OK" "$ARGUMENTS"
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
|
|
59
bin/v-clear-fail2ban
Normal file
59
bin/v-clear-fail2ban
Normal file
|
@ -0,0 +1,59 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Clean fail2ban database
|
||||||
|
# options: NONE
|
||||||
|
#
|
||||||
|
# The function is cleaning fail2ban database
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications & Variable & Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check if fail2ban is installed
|
||||||
|
fail2ban_installed=$(/usr/local/vesta/bin/v-list-sys-services | grep -c 'fail2ban')
|
||||||
|
if [ $fail2ban_installed -eq 0 ]; then
|
||||||
|
echo "Fail2ban is not installed"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Cleaning fail2ban database
|
||||||
|
fail2ban_running=$(/usr/local/vesta/bin/v-list-sys-services | grep 'fail2ban' | grep -c 'running')
|
||||||
|
if [ $fail2ban_running -eq 1 ]; then
|
||||||
|
echo "== Stopping fail2ban"
|
||||||
|
systemctl stop fail2ban
|
||||||
|
fi
|
||||||
|
if [ -f "/var/lib/fail2ban/fail2ban.sqlite3" ]; then
|
||||||
|
echo "== Cleaning fail2ban database"
|
||||||
|
rm /var/lib/fail2ban/fail2ban.sqlite3
|
||||||
|
if [ -f "/etc/nginx/conf.d/block.conf" ]; then
|
||||||
|
echo "== Cleaning nginx block.conf"
|
||||||
|
truncate -s 0 /etc/nginx/conf.d/block.conf
|
||||||
|
nginx_running=$(/usr/local/vesta/bin/v-list-sys-services | grep 'nginx' | grep -c 'running')
|
||||||
|
if [ $nginx_running -eq 1 ]; then
|
||||||
|
echo "== Restarting nginx"
|
||||||
|
systemctl restart nginx
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ $fail2ban_running -eq 1 ]; then
|
||||||
|
echo "== Starting fail2ban"
|
||||||
|
systemctl start fail2ban
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "== Done, fail2ban database cleaned"
|
||||||
|
|
||||||
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
|
exit
|
|
@ -20,6 +20,7 @@ if [ $# -lt 2 ]; then
|
||||||
echo "--TO_DATABASE_USERNAME=..."
|
echo "--TO_DATABASE_USERNAME=..."
|
||||||
echo "--TO_DATABASE_PASSWORD=..."
|
echo "--TO_DATABASE_PASSWORD=..."
|
||||||
echo "--SITE_SUBFOLDER=..."
|
echo "--SITE_SUBFOLDER=..."
|
||||||
|
echo "--EXCLUDE_UPLOADS=1 (or do not set it)"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -313,6 +314,7 @@ echo "FROM_DOMAIN_PROXY_TPL = $FROM_DOMAIN_PROXY_TPL"
|
||||||
echo "FROM_DOMAIN_PROXY_EXT = $FROM_DOMAIN_PROXY_EXT"
|
echo "FROM_DOMAIN_PROXY_EXT = $FROM_DOMAIN_PROXY_EXT"
|
||||||
echo "SEARCH_FOR_CONFIGS_DATABASE_NAME = $SEARCH_FOR_CONFIGS_DATABASE_NAME"
|
echo "SEARCH_FOR_CONFIGS_DATABASE_NAME = $SEARCH_FOR_CONFIGS_DATABASE_NAME"
|
||||||
echo "SEARCH_FOR_CONFIGS_DATABASE_USERNAME = $SEARCH_FOR_CONFIGS_DATABASE_USERNAME"
|
echo "SEARCH_FOR_CONFIGS_DATABASE_USERNAME = $SEARCH_FOR_CONFIGS_DATABASE_USERNAME"
|
||||||
|
echo "EXCLUDE_UPLOADS = $EXCLUDE_UPLOADS"
|
||||||
echo "==============================================================================="
|
echo "==============================================================================="
|
||||||
read -p "=== Press Enter to continue ==="
|
read -p "=== Press Enter to continue ==="
|
||||||
|
|
||||||
|
@ -370,17 +372,25 @@ if [ -d "/root/temp" ]; then
|
||||||
fi
|
fi
|
||||||
mkdir -p /root/temp
|
mkdir -p /root/temp
|
||||||
cd /root/temp
|
cd /root/temp
|
||||||
mysqldump $FROM_DATABASE_NAME > $FROM_DATABASE_NAME.sql
|
mysqldump --max_allowed_packet=1024M $FROM_DATABASE_NAME > $FROM_DATABASE_NAME.sql
|
||||||
echo "=== Importing to database $TO_DATABASE_NAME"
|
echo "=== Importing to database $TO_DATABASE_NAME"
|
||||||
mysql $TO_DATABASE_NAME < $FROM_DATABASE_NAME.sql
|
mysql $TO_DATABASE_NAME < $FROM_DATABASE_NAME.sql
|
||||||
|
rm $FROM_DATABASE_NAME.sql
|
||||||
|
|
||||||
|
EXCLUDE=''
|
||||||
|
if [ ! -z "$EXCLUDE_UPLOADS" ]; then
|
||||||
|
EXCLUDE="--exclude '/wp-content/uploads/*'"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "=== Copying files from $FROM_FOLDER to folder $TO_FOLDER"
|
echo "=== Copying files from $FROM_FOLDER to folder $TO_FOLDER"
|
||||||
if [ "$SITE_SUBFOLDER" != ".." ]; then
|
if [ "$SITE_SUBFOLDER" != ".." ]; then
|
||||||
echo "====== Executing: rsync -a --delete $FROM_FOLDER/ $TO_FOLDER/"
|
run="rsync -a --delete $EXCLUDE $FROM_FOLDER/ $TO_FOLDER/"
|
||||||
rsync -a --delete $FROM_FOLDER/ $TO_FOLDER/
|
echo "====== Executing: $run"
|
||||||
|
eval $run
|
||||||
else
|
else
|
||||||
echo "====== Executing: rsync -a --delete --exclude 'logs/*' $FROM_FOLDER/ $TO_FOLDER/"
|
run="rsync -a --delete $EXCLUDE --exclude 'logs/*' $FROM_FOLDER/ $TO_FOLDER/"
|
||||||
rsync -a --delete --exclude 'logs/*' $FROM_FOLDER/ $TO_FOLDER/
|
echo "====== Executing: $run"
|
||||||
|
eval $run
|
||||||
fi
|
fi
|
||||||
echo "=== Chowning to $TO_USER:$TO_USER in folder $TO_FOLDER"
|
echo "=== Chowning to $TO_USER:$TO_USER in folder $TO_FOLDER"
|
||||||
chown -R $TO_USER:$TO_USER $TO_FOLDER
|
chown -R $TO_USER:$TO_USER $TO_FOLDER
|
||||||
|
@ -419,21 +429,37 @@ if [ $IT_IS_WP -eq 0 ]; then
|
||||||
php /root/Search-Replace-DB/srdb.cli.php -h localhost -n "$TO_DATABASE_NAME" -u "$TO_DATABASE_USERNAME" -p "$TO_DATABASE_PASSWORD" -s "/home/$FROM_USER/" -r "/home/$TO_USER/"
|
php /root/Search-Replace-DB/srdb.cli.php -h localhost -n "$TO_DATABASE_NAME" -u "$TO_DATABASE_USERNAME" -p "$TO_DATABASE_PASSWORD" -s "/home/$FROM_USER/" -r "/home/$TO_USER/"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
|
phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$TO_DOMAIN")
|
||||||
cd $TO_FOLDER
|
cd $TO_FOLDER
|
||||||
if [ -d "wp-content/plugins/w3-total-cache" ]; then
|
|
||||||
rm -f wp-content/object-cache.php
|
|
||||||
rm -f wp-content/db.php
|
|
||||||
rm -f wp-content/advanced-cache.php
|
|
||||||
rm -rf wp-content/w3tc-config
|
|
||||||
rm -rf wp-content/plugins/w3-total-cache
|
|
||||||
fi
|
|
||||||
echo "=== Replacing $FROM_DOMAIN to $TO_DOMAIN in database $TO_DATABASE_NAME"
|
echo "=== Replacing $FROM_DOMAIN to $TO_DOMAIN in database $TO_DATABASE_NAME"
|
||||||
sudo -H -u$TO_USER wp search-replace "$FROM_DOMAIN" "$TO_DOMAIN" --precise --all-tables --skip-columns=guid
|
sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp search-replace "$FROM_DOMAIN" "$TO_DOMAIN" --precise --all-tables --skip-columns=guid --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
|
||||||
if [ "$FROM_USER" != "$TO_USER" ]; then
|
if [ "$FROM_USER" != "$TO_USER" ]; then
|
||||||
echo "=== Replacing /home/$FROM_USER/ to /home/$TO_USER/ in database $TO_DATABASE_NAME"
|
echo "=== Replacing /home/$FROM_USER/ to /home/$TO_USER/ in database $TO_DATABASE_NAME"
|
||||||
sudo -H -u$TO_USER wp search-replace "/home/$FROM_USER/" "/home/$TO_USER/" --precise --all-tables --skip-columns=guid
|
sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp search-replace "/home/$FROM_USER/" "/home/$TO_USER/" --precise --all-tables --skip-columns=guid --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
|
||||||
|
fi
|
||||||
|
sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp cache flush --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
|
||||||
|
sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp config shuffle-salts WP_CACHE_KEY_SALT --force --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
|
||||||
|
sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp config shuffle-salts --skip-plugins=$(sudo -H -u$TO_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ----------- Update Wordfence WAF Path -------------
|
||||||
|
|
||||||
|
# Path to .user.ini file in the new domain directory
|
||||||
|
user_ini="/home/$TO_USER/web/$TO_DOMAIN/public_html/.user.ini"
|
||||||
|
|
||||||
|
# Check if .user.ini exists
|
||||||
|
if [ -f "$user_ini" ]; then
|
||||||
|
echo "Updating .user.ini with new path..."
|
||||||
|
|
||||||
|
# Change path from old domain to new domain
|
||||||
|
sed -i "s|/home/.*/public_html|/home/$TO_USER/web/$TO_DOMAIN/public_html|g" $user_ini
|
||||||
|
|
||||||
|
# Check if replacement was successful and update .user.ini
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
echo ".user.ini updated successfully."
|
||||||
|
else
|
||||||
|
echo "Failed to update .user.ini file."
|
||||||
fi
|
fi
|
||||||
sudo -H -u$TO_USER wp cache flush
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "===== DONE ===="
|
echo "===== DONE ===="
|
||||||
|
|
168
bin/v-commander
168
bin/v-commander
|
@ -13,11 +13,14 @@ fi
|
||||||
|
|
||||||
source /etc/profile
|
source /etc/profile
|
||||||
PATH=$PATH:/usr/local/vesta/bin && export PATH
|
PATH=$PATH:/usr/local/vesta/bin && export PATH
|
||||||
echo "======================= mvVesta-commander ================================"
|
if [ $SHOWHEADER -eq 1 ]; then
|
||||||
|
echo "======================= mvVesta-commander ================================"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -f /root/kernelupdate ]; then
|
if [ -f /root/kernelupdate ]; then
|
||||||
rm /root/kernelupdate
|
rm /root/kernelupdate
|
||||||
fi
|
fi
|
||||||
|
apt_updated=0
|
||||||
apt_upgraded=0
|
apt_upgraded=0
|
||||||
quit_on_empty=0
|
quit_on_empty=0
|
||||||
|
|
||||||
|
@ -60,34 +63,36 @@ check_status() {
|
||||||
|
|
||||||
myhelp() {
|
myhelp() {
|
||||||
echo "---------- Press: -----------"
|
echo "---------- Press: -----------"
|
||||||
echo "u = apt-get update"
|
echo "a = Activate Email rate limit"
|
||||||
echo "g = apt-get upgrade"
|
echo "b = bash"
|
||||||
echo "c = check status"
|
echo "c = check status"
|
||||||
|
echo "d = df -h"
|
||||||
echo "e = make sure Apache is in mpm_event"
|
echo "e = make sure Apache is in mpm_event"
|
||||||
echo "s = download sury.org apt-get key"
|
echo "f = free -h"
|
||||||
|
echo "g = apt-get upgrade"
|
||||||
|
echo "h = help"
|
||||||
echo "m = install php-memcached"
|
echo "m = install php-memcached"
|
||||||
echo "p = set version of php as default"
|
echo "p = set version of php as default"
|
||||||
|
echo "q = quit"
|
||||||
|
echo "r = reboot"
|
||||||
|
echo "s = download sury.org apt-get key"
|
||||||
|
echo "t = clean the trash"
|
||||||
|
echo "u = apt-get update"
|
||||||
echo "v = update myVesta"
|
echo "v = update myVesta"
|
||||||
echo "vo = update myVesta without 'apt-get update'"
|
echo "vo = update myVesta without 'apt-get update'"
|
||||||
echo "t = clean the trash"
|
|
||||||
echo "w = w"
|
echo "w = w"
|
||||||
echo "d = df -h"
|
|
||||||
echo "f = free -h"
|
|
||||||
echo "b = bash"
|
|
||||||
echo "r = reboot"
|
|
||||||
echo "q = quit"
|
|
||||||
echo "h = help"
|
|
||||||
echo "-----------------------------"
|
echo "-----------------------------"
|
||||||
echo "inst v = install myVesta"
|
echo "inst v = install myVesta"
|
||||||
echo "inst p = install multi-php"
|
echo "inst p = install multi-php"
|
||||||
echo "inst pgw = install php-gate"
|
echo "inst pgw = install php-gate"
|
||||||
echo "inst r = install new Roundcube"
|
echo "inst r = install new Roundcube"
|
||||||
echo "inst memcached = install memcached"
|
echo "inst memcached = install memcached"
|
||||||
echo "inst redis = install Redis"
|
echo "inst redis = install Redis"
|
||||||
|
echo "inst nginx-rate-limit = install nginx-rate-limit templates"
|
||||||
echo "dis fb = stop and disable fail2ban"
|
echo "dis fb = stop and disable fail2ban"
|
||||||
echo "dis dove = stop and disable dovecot"
|
echo "dis dove = stop and disable dovecot"
|
||||||
echo "dis spam = stop and disable spam"
|
echo "dis spam = stop and disable spamassassin"
|
||||||
echo "dis clam = stop and disable clamav"
|
echo "dis clam = stop and disable ClamAV"
|
||||||
echo "p 7.0 = set default php 7.0"
|
echo "p 7.0 = set default php 7.0"
|
||||||
echo "p 7.3 = set default php 7.3"
|
echo "p 7.3 = set default php 7.3"
|
||||||
echo "p 7.4 = set default php 7.4"
|
echo "p 7.4 = set default php 7.4"
|
||||||
|
@ -96,20 +101,38 @@ myhelp() {
|
||||||
echo "m def = install php-memcached if needed"
|
echo "m def = install php-memcached if needed"
|
||||||
echo "check fc = check if FreshClam is up"
|
echo "check fc = check if FreshClam is up"
|
||||||
echo "-----------------------------"
|
echo "-----------------------------"
|
||||||
echo "enable-ssh-root-password-login = Allow root password authentication via SSH and set the root password to match the password for the admin account"
|
echo "enable-ssh-root-password-login = Allow root password authentication via SSH"
|
||||||
|
echo "id_rsa = generate id_rsa and id_rsa.pub if it does not exist and show id_rsa.pub"
|
||||||
echo "-----------------------------"
|
echo "-----------------------------"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
apt_update() {
|
||||||
|
echo "============================="
|
||||||
|
echo "== running: apt-get update"
|
||||||
|
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
|
if [ "$release" -lt 10 ]; then
|
||||||
|
apt-get update
|
||||||
|
else
|
||||||
|
apt-get update --allow-releaseinfo-change
|
||||||
|
fi
|
||||||
|
apt_updated=1
|
||||||
|
}
|
||||||
|
|
||||||
COUNTER=0
|
COUNTER=0
|
||||||
|
HAS_PARAMETERS=0
|
||||||
|
|
||||||
while true
|
while true
|
||||||
do
|
do
|
||||||
|
|
||||||
COUNTER=$((COUNTER + 1))
|
COUNTER=$((COUNTER + 1))
|
||||||
if [ $COUNTER -le $numargs ]; then
|
if [ $COUNTER -le $numargs ]; then
|
||||||
|
HAS_PARAMETERS=1
|
||||||
answer=$1
|
answer=$1
|
||||||
shift
|
shift
|
||||||
else
|
else
|
||||||
|
if [ $HAS_PARAMETERS -eq 1 ]; then
|
||||||
|
exit;
|
||||||
|
fi
|
||||||
read -p 'What to do: ' answer
|
read -p 'What to do: ' answer
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -126,17 +149,42 @@ do
|
||||||
if [ "$answer" = 'quit-on-empty' ]; then
|
if [ "$answer" = 'quit-on-empty' ]; then
|
||||||
echo "== the script will quit on next enter"
|
echo "== the script will quit on next enter"
|
||||||
quit_on_empty=1
|
quit_on_empty=1
|
||||||
|
HAS_PARAMETERS=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$answer" = 'a' ] || [ "$answer" = 'A' ]; then
|
||||||
|
mv /etc/exim4/exim4.conf.template /etc/exim4/exim4.conf.template-backup
|
||||||
|
cp /usr/local/vesta/install/debian/12/exim/exim4.conf.template /etc/exim4/exim4.conf.template
|
||||||
|
|
||||||
|
touch /etc/exim4/limit_per_email_account_max_sent_emails_per_hour
|
||||||
|
touch /etc/exim4/limit_per_email_account_max_recipients
|
||||||
|
touch /etc/exim4/limit_per_hosting_account_max_sent_emails_per_hour
|
||||||
|
touch /etc/exim4/limit_per_hosting_account_max_recipients
|
||||||
|
|
||||||
|
check_grep=$(grep -c '#SPAMASSASSIN' /etc/exim4/exim4.conf.template-backup)
|
||||||
|
if [ "$check_grep" -eq 0 ]; then
|
||||||
|
sed -i "s|#SPAMASSASSIN|SPAMASSASSIN|g" /etc/exim4/exim4.conf.template
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_grep=$(grep -c '#SPAM_SCORE' /etc/exim4/exim4.conf.template-backup)
|
||||||
|
if [ "$check_grep" -eq 0 ]; then
|
||||||
|
sed -i "s|#SPAM_SCORE|SPAM_SCORE|g" /etc/exim4/exim4.conf.template
|
||||||
|
fi
|
||||||
|
|
||||||
|
check_grep=$(grep -c '#CLAMD' /etc/exim4/exim4.conf.template-backup)
|
||||||
|
if [ "$check_grep" -eq 0 ]; then
|
||||||
|
sed -i "s|#CLAMD|CLAMD|g" /etc/exim4/exim4.conf.template
|
||||||
|
fi
|
||||||
|
|
||||||
|
systemctl restart exim4
|
||||||
|
echo "Email rate limit activated."
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if [ "$answer" = 'u' ] || [ "$answer" = 'U' ]; then
|
if [ "$answer" = 'u' ] || [ "$answer" = 'U' ]; then
|
||||||
echo "============================="
|
apt_update
|
||||||
echo "== running: apt-get update"
|
|
||||||
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
|
||||||
if [ "$release" -lt 10 ]; then
|
|
||||||
apt-get update
|
|
||||||
else
|
|
||||||
apt-get update --allow-releaseinfo-change
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$answer" = 'g' ] || [ "$answer" = 'G' ]; then
|
if [ "$answer" = 'g' ] || [ "$answer" = 'G' ]; then
|
||||||
|
@ -241,8 +289,14 @@ do
|
||||||
if [ "$answer" = 'dis spam' ] || [ "$answer" = 'DIS SPAM' ]; then
|
if [ "$answer" = 'dis spam' ] || [ "$answer" = 'DIS SPAM' ]; then
|
||||||
echo "============================="
|
echo "============================="
|
||||||
echo "== disabling SpamAssassin"
|
echo "== disabling SpamAssassin"
|
||||||
systemctl stop spamassassin.service
|
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
systemctl disable spamassassin.service
|
if [ "$release" -lt 12 ]; then
|
||||||
|
systemctl stop spamassassin.service
|
||||||
|
systemctl disable spamassassin.service
|
||||||
|
else
|
||||||
|
systemctl stop spamd.service
|
||||||
|
systemctl disable spamd.service
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i "s/^SPAMASSASSIN =/#SPAMASSASSIN =/g" /etc/exim4/exim4.conf.template
|
sed -i "s/^SPAMASSASSIN =/#SPAMASSASSIN =/g" /etc/exim4/exim4.conf.template
|
||||||
sed -i "s/^SPAM_SCORE =/#SPAM_SCORE =/g" /etc/exim4/exim4.conf.template
|
sed -i "s/^SPAM_SCORE =/#SPAM_SCORE =/g" /etc/exim4/exim4.conf.template
|
||||||
|
@ -354,32 +408,13 @@ do
|
||||||
echo "============================="
|
echo "============================="
|
||||||
echo "== cleaning trash"
|
echo "== cleaning trash"
|
||||||
df -m
|
df -m
|
||||||
ps -Af | grep tailf | grep -v "grep tailf"
|
|
||||||
if [ -f "/usr/local/bin/tailf_apache_error.php" ]; then
|
|
||||||
kill $(ps aux | grep 'tailf_apache_error' | grep -v "grep tailf_apache_error" | awk '{print $2}')
|
|
||||||
fi
|
|
||||||
if [ -f "/usr/local/bin/tailf_exim.php" ]; then
|
|
||||||
kill $(ps aux | grep 'tailf_exim' | grep -v "grep tailf_exim" | awk '{print $2}')
|
|
||||||
fi
|
|
||||||
echo "------"
|
echo "------"
|
||||||
ps -Af | grep tailf | grep -v "grep tailf"
|
ps -Af | grep tailf | grep -v "grep tailf"
|
||||||
echo "------"
|
echo "------"
|
||||||
sleep 2
|
|
||||||
truncate -s 0 /*.log
|
|
||||||
rm /panic-*.log
|
|
||||||
rm /var/log/panic-*.log
|
|
||||||
/usr/local/vesta/bin/v-clean-garbage
|
/usr/local/vesta/bin/v-clean-garbage
|
||||||
sleep 2
|
|
||||||
if [ -f "/usr/local/bin/tailf_apache_error.php" ]; then
|
|
||||||
nohup php /usr/local/bin/tailf_apache_error.php > /var/log/tailf_apache_error.log &
|
|
||||||
fi
|
|
||||||
if [ -f "/usr/local/bin/tailf_exim.php" ]; then
|
|
||||||
nohup php /usr/local/bin/tailf_exim.php > /var/log/tailf_exim.log &
|
|
||||||
fi
|
|
||||||
echo "--------------"
|
echo "--------------"
|
||||||
df -m
|
df -m
|
||||||
echo "--------------"
|
echo "--------------"
|
||||||
sleep 2
|
|
||||||
ps -Af | grep tailf | grep -v "grep tailf"
|
ps -Af | grep tailf | grep -v "grep tailf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -438,8 +473,8 @@ do
|
||||||
memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
|
memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
|
||||||
apt-get update
|
apt-get update
|
||||||
apt-get -y install memcached
|
apt-get -y install memcached
|
||||||
apt-get install $(systemctl --full --type service --all | grep "php...-fpm" | sed 's#●##g' | awk '{print $1}' | cut -c1-6 | xargs -n 1 printf "%s-memcache ")
|
apt-get -y install $(systemctl --full --type service --all | grep "php...-fpm" | sed 's#●##g' | awk '{print $1}' | cut -c1-6 | xargs -n 1 printf "%s-memcache ")
|
||||||
apt-get install $(systemctl --full --type service --all | grep "php...-fpm" | sed 's#●##g' | awk '{print $1}' | cut -c1-6 | xargs -n 1 printf "%s-memcached ")
|
apt-get -y install $(systemctl --full --type service --all | grep "php...-fpm" | sed 's#●##g' | awk '{print $1}' | cut -c1-6 | xargs -n 1 printf "%s-memcached ")
|
||||||
if [ $memory -lt 15000000 ]; then
|
if [ $memory -lt 15000000 ]; then
|
||||||
sed -i "s/-m 64/-m 256/" /etc/memcached.conf
|
sed -i "s/-m 64/-m 256/" /etc/memcached.conf
|
||||||
else
|
else
|
||||||
|
@ -460,6 +495,7 @@ do
|
||||||
|
|
||||||
sed -i "s|^supervised no|supervised systemd|g" /etc/redis/redis.conf
|
sed -i "s|^supervised no|supervised systemd|g" /etc/redis/redis.conf
|
||||||
sed -i "s|^save |# save |g" /etc/redis/redis.conf
|
sed -i "s|^save |# save |g" /etc/redis/redis.conf
|
||||||
|
sed -i 's|^# save ""|save ""|g' /etc/redis/redis.conf
|
||||||
if [ $memory -lt 15000000 ]; then
|
if [ $memory -lt 15000000 ]; then
|
||||||
sed -i "s|^# maxmemory .*|maxmemory 256m|g" /etc/redis/redis.conf
|
sed -i "s|^# maxmemory .*|maxmemory 256m|g" /etc/redis/redis.conf
|
||||||
else
|
else
|
||||||
|
@ -472,6 +508,15 @@ do
|
||||||
echo "-------------------"
|
echo "-------------------"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$answer" = 'inst nginx-rate-limit' ] || [ "$answer" = 'INST NGINX-RATE-LIMIT' ]; then
|
||||||
|
echo "============================="
|
||||||
|
echo "== Installing inst nginx-rate-limit templates"
|
||||||
|
curl -O https://c.myvestacp.com/tools/rate-limit-tpl/install_rate_limit_tpl.sh
|
||||||
|
bash install_rate_limit_tpl.sh
|
||||||
|
echo "== nginx-rate-limit templates installed."
|
||||||
|
echo "-------------------"
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$answer" = 'check fc' ] || [ "$answer" = 'CHECK FC' ]; then
|
if [ "$answer" = 'check fc' ] || [ "$answer" = 'CHECK FC' ]; then
|
||||||
echo "== Checking if FreshClam is up"
|
echo "== Checking if FreshClam is up"
|
||||||
clamavup=$(/usr/local/vesta/bin/v-list-sys-services | grep 'clamav-daemon' | grep -c 'running')
|
clamavup=$(/usr/local/vesta/bin/v-list-sys-services | grep 'clamav-daemon' | grep -c 'running')
|
||||||
|
@ -490,21 +535,13 @@ do
|
||||||
echo "--- New settings ---"
|
echo "--- New settings ---"
|
||||||
grep '^PermitRoot' /etc/ssh/sshd_config
|
grep '^PermitRoot' /etc/ssh/sshd_config
|
||||||
echo "--------------------"
|
echo "--------------------"
|
||||||
adminline=$(grep '^admin:' /etc/shadow)
|
|
||||||
adminline=${adminline:6}
|
|
||||||
adminline="root:$adminline"
|
|
||||||
sed -i "s#^root:.*#$adminline#" /etc/shadow
|
|
||||||
echo "root password is now the same as admin password."
|
|
||||||
echo "--------------------"
|
|
||||||
grep '^root:' /etc/shadow
|
|
||||||
grep '^admin:' /etc/shadow
|
|
||||||
echo "--------------------"
|
|
||||||
echo "Port 22 opened in Firewall for all IP addresses."
|
echo "Port 22 opened in Firewall for all IP addresses."
|
||||||
/usr/local/vesta/bin/v-unsuspend-firewall-rule "11"
|
/usr/local/vesta/bin/v-unsuspend-firewall-rule "11"
|
||||||
echo "--------------------"
|
echo "--------------------"
|
||||||
|
echo "Type 'passwd' in the terminal to set the root password."
|
||||||
|
echo "--------------------"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
if [ "$answer" = 'r' ] || [ "$answer" = 'R' ]; then
|
if [ "$answer" = 'r' ] || [ "$answer" = 'R' ]; then
|
||||||
echo "============================="
|
echo "============================="
|
||||||
echo "== Rebooting the server"
|
echo "== Rebooting the server"
|
||||||
|
@ -554,4 +591,13 @@ do
|
||||||
/root/install-new-roundcube.sh
|
/root/install-new-roundcube.sh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ "$answer" = 'id_rsa' ] || [ "$answer" = 'ID_RSA' ]; then
|
||||||
|
if [ ! -f "/root/.ssh/id_rsa.pub" ]; then
|
||||||
|
ssh-keygen -q -t rsa -N '' -C "$HOSTNAME" -b 4096 -f /root/.ssh/id_rsa 2>/dev/null <<< y >/dev/null
|
||||||
|
fi
|
||||||
|
echo "=== YOUR id_rsa.pub IS BELOW ==="
|
||||||
|
cat /root/.ssh/id_rsa.pub
|
||||||
|
echo "======"
|
||||||
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
69
bin/v-delete-database-of-domain
Normal file
69
bin/v-delete-database-of-domain
Normal file
|
@ -0,0 +1,69 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete database if domain has database
|
||||||
|
# options: DOMAIN
|
||||||
|
#
|
||||||
|
# The function for deleting database if domain has database
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
domain=$1
|
||||||
|
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
USER=$user
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
check_result $E_NOTEXIST "domain $domain doesn't exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'DOMAIN'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
RET=$OK
|
||||||
|
|
||||||
|
# echo "================================="
|
||||||
|
r=$(/usr/local/vesta/bin/v-get-database-credentials-of-domain $domain)
|
||||||
|
# echo $r
|
||||||
|
eval $r
|
||||||
|
# echo "================================="
|
||||||
|
|
||||||
|
if [ ! -z "$DATABASE_NAME" ]; then
|
||||||
|
echo "=== v-delete-database $USER $DATABASE_NAME"
|
||||||
|
/usr/local/vesta/bin/v-delete-database $USER $DATABASE_NAME
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
echo "=== v-delete-database failed"
|
||||||
|
RET=$E_NOTEXIST
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
log_event "$RET" "$ARGUMENTS"
|
||||||
|
|
||||||
|
exit
|
|
@ -37,9 +37,10 @@ is_object_unsuspended 'user' 'USER' "$user"
|
||||||
if [ ! -z "$WEB_SYSTEM" ]; then
|
if [ ! -z "$WEB_SYSTEM" ]; then
|
||||||
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
|
str=$(grep "DOMAIN='$domain'" $USER_DATA/web.conf)
|
||||||
if [ ! -z "$str" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
|
$BIN/v-delete-database-of-domain $domain
|
||||||
domain_found='yes'
|
domain_found='yes'
|
||||||
$BIN/v-delete-web-domain $user $domain 'no'
|
$BIN/v-delete-web-domain $user $domain 'no'
|
||||||
check_result $? "can't suspend web" > /dev/null
|
check_result $? "can't delete web" > /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ if [ ! -z "$DNS_SYSTEM" ]; then
|
||||||
if [ ! -z "$str" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
domain_found='yes'
|
domain_found='yes'
|
||||||
$BIN/v-delete-dns-domain $user $domain 'no'
|
$BIN/v-delete-dns-domain $user $domain 'no'
|
||||||
check_result $? "can't suspend dns" > /dev/null
|
check_result $? "can't delete dns" > /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -59,7 +60,7 @@ if [ ! -z "$MAIL_SYSTEM" ]; then
|
||||||
if [ ! -z "$str" ]; then
|
if [ ! -z "$str" ]; then
|
||||||
domain_found='yes'
|
domain_found='yes'
|
||||||
$BIN/v-delete-mail-domain $user $domain
|
$BIN/v-delete-mail-domain $user $domain
|
||||||
check_result $? "can't suspend mail" > /dev/null
|
check_result $? "can't delete mail" > /dev/null
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,11 @@ $iptables -D fail2ban-$chain $b 2>/dev/null
|
||||||
# Changing permissions
|
# Changing permissions
|
||||||
chmod 660 $conf
|
chmod 660 $conf
|
||||||
|
|
||||||
|
# nginx deny rules conf
|
||||||
|
if [ "$chain" = "WEB" ] && [ -f "/etc/nginx/conf.d/block.conf" ]; then
|
||||||
|
sed -i "/deny $ip;/d" /etc/nginx/conf.d/block.conf
|
||||||
|
systemctl reload nginx
|
||||||
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
|
|
|
@ -34,12 +34,21 @@ is_object_valid '../../data/firewall/rules' 'RULE' "$rule"
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
oldvalues=$(grep "RULE='$rule'" $VESTA/data/firewall/rules.conf)
|
||||||
|
|
||||||
# Deleting rule
|
# Deleting rule
|
||||||
sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf
|
sed -i "/RULE='$rule' /d" $VESTA/data/firewall/rules.conf
|
||||||
|
|
||||||
# Updating system firewall
|
# Updating system firewall
|
||||||
$BIN/v-update-firewall
|
$BIN/v-update-firewall
|
||||||
|
|
||||||
|
if [ "$WEB_SYSTEM" == 'nginx' ] || [ "$PROXY_SYSTEM" == 'nginx' ]; then
|
||||||
|
parse_object_kv_list_non_eval "$oldvalues"
|
||||||
|
if [ "$PORT" == "80,443" ] && [ "$ACTION" == "DROP" ]; then
|
||||||
|
sed -i "/$IP/d" /etc/nginx/conf.d/block-firewall.conf
|
||||||
|
systemctl restart nginx
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
|
|
|
@ -51,6 +51,9 @@ if [[ "$MAIL_SYSTEM" =~ exim ]]; then
|
||||||
rm -f /etc/$MAIL_SYSTEM/domains/$domain_idn
|
rm -f /etc/$MAIL_SYSTEM/domains/$domain_idn
|
||||||
rm -rf $HOMEDIR/$user/conf/mail/$domain
|
rm -rf $HOMEDIR/$user/conf/mail/$domain
|
||||||
rm -rf $HOMEDIR/$user/mail/$domain_idn
|
rm -rf $HOMEDIR/$user/mail/$domain_idn
|
||||||
|
if [ -d "/hdd/home/$user/mail/$domain_idn" ]; then
|
||||||
|
rm -rf /hdd/home/$user/mail/$domain_idn
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Deleting dkim dns record
|
# Deleting dkim dns record
|
||||||
|
|
|
@ -48,7 +48,7 @@ fi
|
||||||
# Deleting dns record
|
# Deleting dns record
|
||||||
if [ ! -z "$DNS_SYSTEM" ] && [ -e "$USER_DATA/dns/$domain.conf" ]; then
|
if [ ! -z "$DNS_SYSTEM" ] && [ -e "$USER_DATA/dns/$domain.conf" ]; then
|
||||||
records=$($BIN/v-list-dns-records $user $domain plain)
|
records=$($BIN/v-list-dns-records $user $domain plain)
|
||||||
dkim_records=$(echo "$records" |grep -w '_domainkey' | cut -f 1 -d ' ')
|
dkim_records=$(echo "$records" |grep -w '_domainkey' | awk '{print $1}')
|
||||||
for id in $dkim_records; do
|
for id in $dkim_records; do
|
||||||
$BIN/v-delete-dns-record $user $domain $id
|
$BIN/v-delete-dns-record $user $domain $id
|
||||||
done
|
done
|
||||||
|
|
127
bin/v-delete-mails
Normal file
127
bin/v-delete-mails
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: delete old emails (by mtime) for user/domain/account, with optional scope
|
||||||
|
# usage: v-delete-mails USER DOMAIN ACCOUNT MTIME_DAYS|all SCOPE
|
||||||
|
# SCOPE: all – clean every Maildir folder (cur, new, tmp, custom subfolders)
|
||||||
|
# trash – clean only Trash/Junk/Spam folders
|
||||||
|
|
||||||
|
# load Vesta functions & config
|
||||||
|
source "$VESTA/func/main.sh"
|
||||||
|
source "$VESTA/conf/vesta.conf"
|
||||||
|
|
||||||
|
# read arguments
|
||||||
|
user="$1"
|
||||||
|
domain="$2"
|
||||||
|
account="$3"
|
||||||
|
mtime="$4"
|
||||||
|
scope="$5"
|
||||||
|
|
||||||
|
# verify argument count
|
||||||
|
check_args '5' "$#" 'USER DOMAIN ACCOUNT MTIME_DAYS|all SCOPE'
|
||||||
|
|
||||||
|
# validate scope
|
||||||
|
if [[ "$scope" != "all" && "$scope" != "trash" ]]; then
|
||||||
|
echo "ERROR: SCOPE must be 'all' or 'trash'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# validate logical combinations
|
||||||
|
if [[ "$user" == "all" ]]; then
|
||||||
|
if [[ "$domain" != "all" || "$account" != "all" ]]; then
|
||||||
|
echo "ERROR: When USER is 'all', both DOMAIN and ACCOUNT must be 'all'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
elif [[ "$domain" == "all" && "$account" != "all" ]]; then
|
||||||
|
echo "ERROR: When DOMAIN is 'all', ACCOUNT must also be 'all'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# build a detailed summary for the warning
|
||||||
|
declare -a summary_parts
|
||||||
|
if [[ "$user" == "all" ]]; then
|
||||||
|
summary_parts+=("all users")
|
||||||
|
else
|
||||||
|
summary_parts+=("user '$user'")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$domain" == "all" ]]; then
|
||||||
|
summary_parts+=("all domains")
|
||||||
|
else
|
||||||
|
summary_parts+=("domain '$domain'")
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ "$account" == "all" ]]; then
|
||||||
|
summary_parts+=("all accounts")
|
||||||
|
else
|
||||||
|
summary_parts+=("account '$account'")
|
||||||
|
fi
|
||||||
|
|
||||||
|
# join with commas
|
||||||
|
summary=$(printf ", %s" "${summary_parts[@]}")
|
||||||
|
summary=${summary:2}
|
||||||
|
|
||||||
|
# only warn if any of them is 'all' or if mtime is 'all'
|
||||||
|
if [[ "$mtime" == "all" || "$user" == "all" || "$domain" == "all" || "$account" == "all" ]]; then
|
||||||
|
echo "WARNING: This will delete emails older than '$mtime' days for ${summary}."
|
||||||
|
read -p "Are you sure? (yes/no): " confirm
|
||||||
|
[[ "$confirm" != "yes" ]] && { echo "Aborted."; exit 1; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
# function to delete emails
|
||||||
|
delete_emails() {
|
||||||
|
local u="$1" d="$2" a="$3"
|
||||||
|
local maildir="/home/$u/mail/$d/$a"
|
||||||
|
|
||||||
|
[[ ! -d "$maildir" ]] && return
|
||||||
|
|
||||||
|
echo "→ Cleaning '$a@$d' (user: $u), scope: $scope, mtime: $mtime"
|
||||||
|
|
||||||
|
# build find predicates
|
||||||
|
if [[ "$scope" == "all" ]]; then
|
||||||
|
folder_expr=( -path "*/cur/*" -o -path "*/new/*" -o -path "*/tmp/*" )
|
||||||
|
else
|
||||||
|
folder_expr=( -ipath "*/trash/*" -o -ipath "*/junk/*" -o -ipath "*/spam/*" )
|
||||||
|
fi
|
||||||
|
|
||||||
|
# assemble and run find
|
||||||
|
if [[ "$mtime" == "all" ]]; then
|
||||||
|
find "$maildir" -type f \( "${folder_expr[@]}" \) -print -delete 2>/dev/null
|
||||||
|
else
|
||||||
|
find "$maildir" -type f \( "${folder_expr[@]}" \) -mtime +"$mtime" -print -delete 2>/dev/null
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
# collect users
|
||||||
|
if [[ "$user" == "all" ]]; then
|
||||||
|
users=$(v-list-users plain | awk '{print $1}')
|
||||||
|
else
|
||||||
|
users="$user"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# iterate through users, domains, accounts
|
||||||
|
for u in $users; do
|
||||||
|
if [[ "$domain" == "all" ]]; then
|
||||||
|
domains=$(v-list-mail-domains "$u" plain | awk '{print $1}')
|
||||||
|
else
|
||||||
|
domains="$domain"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for d in $domains; do
|
||||||
|
if [[ "$account" == "all" ]]; then
|
||||||
|
accounts=$(v-list-mail-accounts "$u" "$d" plain | awk '{print $1}')
|
||||||
|
else
|
||||||
|
accounts="$account"
|
||||||
|
fi
|
||||||
|
|
||||||
|
for a in $accounts; do
|
||||||
|
delete_emails "$u" "$d" "$a"
|
||||||
|
done
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
# restart dovecot to refresh mailbox state
|
||||||
|
systemctl restart dovecot
|
||||||
|
|
||||||
|
# log the action (status first, then message)
|
||||||
|
log_event "$OK" "Deleted emails (>$mtime days, scope=$scope) for $user $domain $account"
|
||||||
|
|
||||||
|
exit 0
|
|
@ -94,6 +94,9 @@ fi
|
||||||
# Deleting user directories
|
# Deleting user directories
|
||||||
chattr -i $HOMEDIR/$user/conf
|
chattr -i $HOMEDIR/$user/conf
|
||||||
rm -rf $HOMEDIR/$user
|
rm -rf $HOMEDIR/$user
|
||||||
|
if [ -d "/hdd/home/$user" ]; then
|
||||||
|
rm -rf /hdd/home/$user
|
||||||
|
fi
|
||||||
rm -f /var/spool/mail/$user
|
rm -f /var/spool/mail/$user
|
||||||
rm -f /var/spool/cron/$user
|
rm -f /var/spool/cron/$user
|
||||||
rm -f /var/spool/cron/crontabs/$user
|
rm -f /var/spool/cron/crontabs/$user
|
||||||
|
|
|
@ -62,36 +62,24 @@ if [ -f "$fpmconf" ]; then
|
||||||
rm $fpmconf
|
rm $fpmconf
|
||||||
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
||||||
fi
|
fi
|
||||||
fpmconf="/etc/php/5.6/fpm/pool.d/$domain.conf"
|
|
||||||
if [ -f "$fpmconf" ]; then
|
for PHPV in /etc/php/*; do
|
||||||
rm $fpmconf
|
if [ -d "${PHPV}" ]; then
|
||||||
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
# PHPVER=$(basename ${PHPV})
|
||||||
fi
|
POOLD="${PHPV}/fpm/pool.d"
|
||||||
fpmconf="/etc/php/7.0/fpm/pool.d/$domain.conf"
|
fpmconf="$POOLD/$domain.conf"
|
||||||
if [ -f "$fpmconf" ]; then
|
if [ -f "$fpmconf" ]; then
|
||||||
rm $fpmconf
|
rm $fpmconf
|
||||||
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
||||||
fi
|
fi
|
||||||
fpmconf="/etc/php/7.1/fpm/pool.d/$domain.conf"
|
POOLD="${PHPV}/fpm/pool.d-ioncube"
|
||||||
if [ -f "$fpmconf" ]; then
|
fpmconf="$POOLD/$domain.conf"
|
||||||
rm $fpmconf
|
if [ -f "$fpmconf" ]; then
|
||||||
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
rm $fpmconf
|
||||||
fi
|
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
||||||
fpmconf="/etc/php/7.2/fpm/pool.d/$domain.conf"
|
fi
|
||||||
if [ -f "$fpmconf" ]; then
|
fi
|
||||||
rm $fpmconf
|
done
|
||||||
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
|
||||||
fi
|
|
||||||
fpmconf="/etc/php/7.3/fpm/pool.d/$domain.conf"
|
|
||||||
if [ -f "$fpmconf" ]; then
|
|
||||||
rm $fpmconf
|
|
||||||
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
|
||||||
fi
|
|
||||||
fpmconf="/etc/php/7.4/fpm/pool.d/$domain.conf"
|
|
||||||
if [ -f "$fpmconf" ]; then
|
|
||||||
rm $fpmconf
|
|
||||||
echo "Deleted: $fpmconf" >> /usr/local/vesta/log/system.log
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Deleting domain from web.conf
|
# Deleting domain from web.conf
|
||||||
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
|
sed -i "/DOMAIN='$domain'/ d" $USER_DATA/web.conf
|
||||||
|
@ -142,6 +130,9 @@ rm -f /var/log/$WEB_SYSTEM/domains/$domain.error*
|
||||||
|
|
||||||
# Deleting directory
|
# Deleting directory
|
||||||
rm -rf $HOMEDIR/$user/web/$domain
|
rm -rf $HOMEDIR/$user/web/$domain
|
||||||
|
if [ -d "/hdd/home/$user/web/$domain" ]; then
|
||||||
|
rm -rf /hdd/home/$user/web/$domain
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
79
bin/v-desinfect-wordpress
Normal file
79
bin/v-desinfect-wordpress
Normal file
|
@ -0,0 +1,79 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: disinfect a WordPress site with several maintenance commands
|
||||||
|
# options: DOMAIN
|
||||||
|
|
||||||
|
# -------------------------------------------------------- #
|
||||||
|
# variables and checks #
|
||||||
|
# -------------------------------------------------------- #
|
||||||
|
|
||||||
|
if [ "$(whoami)" != "root" ]; then
|
||||||
|
echo "You must be root to run this command."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# make sure all Vesta helper scripts are reachable
|
||||||
|
export PATH="/usr/local/vesta/bin:$PATH"
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
domain="$1"
|
||||||
|
if [ -z "$domain" ]; then
|
||||||
|
echo "Usage: v-desinfect-wp DOMAIN"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner "$domain")
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
echo "Domain $domain does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# absolute paths to maintenance scripts, in desired order
|
||||||
|
declare -a tasks=(
|
||||||
|
"/usr/local/vesta/bin/v-change-database-password-for-wordpress"
|
||||||
|
"/usr/local/vesta/bin/v-change-wordpress-admin-passwords"
|
||||||
|
"/usr/local/vesta/bin/v-fix-wordpress-core"
|
||||||
|
"/usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
|
||||||
|
"INTERACTIVE=1 /usr/local/vesta/bin/v-wf-malware-hyperscan-with-remediate"
|
||||||
|
)
|
||||||
|
|
||||||
|
# -------------------------------------------------------- #
|
||||||
|
# execution strategy #
|
||||||
|
# -------------------------------------------------------- #
|
||||||
|
|
||||||
|
echo
|
||||||
|
read -r -p "Run all maintenance steps automatically? (y/n) " run_all < /dev/tty
|
||||||
|
|
||||||
|
if [[ "$run_all" =~ ^[Yy]$ ]]; then
|
||||||
|
echo "Running all maintenance steps for $domain"
|
||||||
|
automatic=true
|
||||||
|
else
|
||||||
|
echo
|
||||||
|
echo "Selective mode. You will be asked for each step."
|
||||||
|
automatic=false
|
||||||
|
fi
|
||||||
|
|
||||||
|
for cmd in "${tasks[@]}"; do
|
||||||
|
if [ ! -x "$cmd" ]; then
|
||||||
|
echo "Command $cmd not found or not executable, skipping."
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$automatic" = false ]; then
|
||||||
|
while true; do
|
||||||
|
read -r -p "Run $(basename "$cmd") for $domain? (y/n) " yn < /dev/tty
|
||||||
|
case "$yn" in
|
||||||
|
[Yy]* ) break ;;
|
||||||
|
[Nn]* ) echo "Skipping $(basename "$cmd")."; continue 2 ;;
|
||||||
|
* ) echo "Please answer y or n." ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "=== $(basename "$cmd") $domain ==="
|
||||||
|
"$cmd" "$domain"
|
||||||
|
done
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo "Done."
|
||||||
|
exit 0
|
90
bin/v-edit-domain-php-ini
Normal file
90
bin/v-edit-domain-php-ini
Normal file
|
@ -0,0 +1,90 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Edit php.ini for certain domain
|
||||||
|
# options: DOMAIN
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
SILENT_MODE=1
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
domain=$1
|
||||||
|
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
USER=$user
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
source /usr/local/vesta/func/domain.sh
|
||||||
|
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
check_result $E_NOTEXIST "domain $domain doesn't exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'DOMAIN'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user" ]; then
|
||||||
|
# echo "User doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
|
||||||
|
# echo "Domain doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
fpm_ver=$(/usr/local/vesta/bin/v-get-php-version-of-domain $domain)
|
||||||
|
|
||||||
|
if [ -z "$fpm_ver" ]; then
|
||||||
|
echo "PHP version for domain $domain could not be determined."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
config_file="/etc/php/${fpm_ver}/fpm/pool.d/${domain}.conf"
|
||||||
|
|
||||||
|
if command -v mcedit >/dev/null; then
|
||||||
|
mcedit "$config_file"
|
||||||
|
else
|
||||||
|
nano "$config_file"
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Restarting PHP-FPM service for PHP version ${fpm_ver}"
|
||||||
|
systemctl restart php${fpm_ver}-fpm
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
systemctl status php${fpm_ver}-fpm
|
||||||
|
echo "========================="
|
||||||
|
echo ""
|
||||||
|
echo "ERROR: php${fpm_ver}-fpm restart failed - please re-run the command and fix the problem !!!"
|
||||||
|
echo ""
|
||||||
|
exit $E_RESTART;
|
||||||
|
else
|
||||||
|
echo "The PHP-FPM service for PHP version ${fpm_ver} has been restarted successfully."
|
||||||
|
fi
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit 0;
|
70
bin/v-edit-php-ini
Normal file
70
bin/v-edit-php-ini
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Edit php.ini for a specific PHP version
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# List available PHP versions and store them into an array
|
||||||
|
mapfile -t php_versions < <(/usr/local/vesta/bin/v-list-php)
|
||||||
|
|
||||||
|
echo "Available PHP versions:"
|
||||||
|
PS3="Please select the PHP version you want to edit php.ini for: "
|
||||||
|
|
||||||
|
select php_version in "${php_versions[@]}"; do
|
||||||
|
if [[ -n $php_version ]]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
echo "Invalid choice. Please try again."
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Define path to the php.ini file
|
||||||
|
php_ini_path="/etc/php/${php_version}/fpm/php.ini"
|
||||||
|
|
||||||
|
# Check if php.ini exists for the selected version
|
||||||
|
if [[ ! -f "$php_ini_path" ]]; then
|
||||||
|
echo "The php.ini file for the selected PHP version ($php_version) does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Determine the text editor to use
|
||||||
|
if command -v mcedit >/dev/null 2>&1; then
|
||||||
|
editor_cmd="mcedit"
|
||||||
|
elif command -v nano >/dev/null 2>&1; then
|
||||||
|
editor_cmd="nano"
|
||||||
|
else
|
||||||
|
echo "No supported text editor found. Please install 'mcedit' or 'nano'."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Open php.ini for the chosen PHP version in the selected editor
|
||||||
|
echo "Opening $php_ini_path in editor $editor_cmd..."
|
||||||
|
$editor_cmd "$php_ini_path"
|
||||||
|
|
||||||
|
# Restart the PHP-FPM service for the selected version
|
||||||
|
echo "Restarting the PHP-FPM service for PHP version $php_version..."
|
||||||
|
systemctl restart php${php_version}-fpm
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
systemctl status php${php_version}-fpm
|
||||||
|
echo "========================="
|
||||||
|
echo ""
|
||||||
|
echo "ERROR: php${php_version}-fpm restart failed - please re-run the command and fix the problem !!!"
|
||||||
|
echo ""
|
||||||
|
exit $E_RESTART;
|
||||||
|
else
|
||||||
|
echo "The PHP-FPM service for PHP version ${php_version} has been restarted successfully."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Exit #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit 0;
|
35
bin/v-fix-php-ini-disable-functions
Normal file
35
bin/v-fix-php-ini-disable-functions
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "/tmp/patched" ]; then rm /tmp/patched; fi;
|
||||||
|
|
||||||
|
echo "=== Fixing php.ini files to have the correct disable_functions line"
|
||||||
|
|
||||||
|
export NOTFOUNDVAL="exec,system,passthru,shell_exec"
|
||||||
|
export LINEBEGINSWITH="disable_functions ="
|
||||||
|
export NEWVAL="disable_functions = pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen"
|
||||||
|
|
||||||
|
find /etc/php/*/fpm/ -type f -name "php.ini" -exec grep -L "$NOTFOUNDVAL" {} \; | xargs sh -c 'found=0; for arg do if [ ! -f "$arg.disable_patching" ]; then if [ $found -eq 0 ]; then echo "== Fixing existing lines"; found=1; touch /tmp/patched; fi; echo "= Patching $arg"; sed -i "s|^$LINEBEGINSWITH.*|$NEWVAL|g" $arg; fi; done' _
|
||||||
|
|
||||||
|
export NOTFOUNDVAL2="^$LINEBEGINSWITH"
|
||||||
|
export REMOVELINETHATCONTAINS=$LINEBEGINSWITH
|
||||||
|
|
||||||
|
find /etc/php/*/fpm/ -type f -name "php.ini" -exec grep -L "$NOTFOUNDVAL2" {} \; | xargs sh -c 'found=0; for arg do if [ ! -f "$arg.disable_patching" ]; then if [ $found -eq 0 ]; then echo "== Adding missing lines"; found=1; touch /tmp/patched; fi; echo "= Patching $arg"; sed -i "s|.*$REMOVELINETHATCONTAINS.*||g" $arg; echo "$NEWVAL" >> $arg; fi; done' _
|
||||||
|
|
||||||
|
if [ -f "/tmp/patched" ]; then
|
||||||
|
rm /tmp/patched
|
||||||
|
|
||||||
|
echo "== Restarting all PHP-FPM services"
|
||||||
|
systemctl --full --type service --all | grep "php...-fpm" | sed 's#●##g' | awk '{print $1}' | xargs systemctl restart
|
||||||
|
|
||||||
|
echo "=== Everything done."
|
||||||
|
else
|
||||||
|
echo "=== Everything is already correct."
|
||||||
|
fi
|
||||||
|
|
||||||
|
exit 0;
|
|
@ -44,7 +44,7 @@ find /home/$user/mail/*/ -type d -exec chmod u+rwx {} \;
|
||||||
find /home/$user/mail/*/ -type d -exec chmod g+rwx {} \;
|
find /home/$user/mail/*/ -type d -exec chmod g+rwx {} \;
|
||||||
find /home/$user/mail/*/ -type f -exec chmod u+rw {} \;
|
find /home/$user/mail/*/ -type f -exec chmod u+rw {} \;
|
||||||
find /home/$user/mail/*/ -type f -exec chmod g+rw {} \;
|
find /home/$user/mail/*/ -type f -exec chmod g+rw {} \;
|
||||||
|
find /home/$user/mail/*/ -maxdepth 1 -type d -exec chmod g-rwx {} \;
|
||||||
|
|
||||||
find /home/$user/conf/dns/ -type f -exec chown root:bind {} \;
|
find /home/$user/conf/dns/ -type f -exec chown root:bind {} \;
|
||||||
find /home/$user/conf/ -type d -exec chown root:root {} \;
|
find /home/$user/conf/ -type d -exec chown root:root {} \;
|
||||||
|
@ -52,6 +52,7 @@ find /home/$user/conf/ -type d -exec chown root:root {} \;
|
||||||
find /home/$user/web/*/public_html/ -type d -exec chmod 755 {} +
|
find /home/$user/web/*/public_html/ -type d -exec chmod 755 {} +
|
||||||
find /home/$user/web/*/public_html/ -type f -exec chmod 644 {} +
|
find /home/$user/web/*/public_html/ -type f -exec chmod 644 {} +
|
||||||
find /home/$user/web/*/public_html/ -exec chown $user:$user {} \;
|
find /home/$user/web/*/public_html/ -exec chown $user:$user {} \;
|
||||||
|
find /home/$user/web/*/ -name "*.php" -type f -exec chmod 600 {} +
|
||||||
|
|
||||||
echo "Done, permissions fixed for user: $user"
|
echo "Done, permissions fixed for user: $user"
|
||||||
|
|
||||||
|
|
88
bin/v-fix-website-permissions
Normal file
88
bin/v-fix-website-permissions
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Fixing chown and chmod permissions in the public_html directory
|
||||||
|
# options: DOMAIN
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
domain=$1
|
||||||
|
|
||||||
|
# Check if number of arguments is 2
|
||||||
|
if [ $# -eq 2 ]; then
|
||||||
|
user=$2
|
||||||
|
else
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
fi
|
||||||
|
USER=$user
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
check_result $E_NOTEXIST "domain $domain doesn't exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'DOMAIN'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user" ]; then
|
||||||
|
echo "User doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
|
||||||
|
echo "Domain doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Going to domain directory
|
||||||
|
cd /home/$USER/web/$domain
|
||||||
|
|
||||||
|
# Ownership check
|
||||||
|
if [ -z "$SKIP_OWNERSHIP_CHECK" ] && [ -f "public_html/index.php" ]; then
|
||||||
|
owner=$(stat -c '%U' "public_html/index.php")
|
||||||
|
if [ "$owner" = "root" ] || [ "$owner" = "www-data" ]; then
|
||||||
|
echo "Skipping permission fix for $domain, because v-lock-wordpress is used (index.php is owned by $owner)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
echo "Updating permissions for /home/$USER/web/$domain/public_html/"
|
||||||
|
find public_html/ -type d -exec chmod 755 {} +
|
||||||
|
find public_html/ -type f -exec chmod 644 {} +
|
||||||
|
chown -R $USER:$USER public_html/
|
||||||
|
|
||||||
|
# Setting chmod 600 for all php files
|
||||||
|
echo "= Setting chmod 600 for all php files"
|
||||||
|
find -name "*.php" -type f -exec chmod 600 {} +
|
||||||
|
find -name ".env" -type f -exec chmod 600 {} +
|
||||||
|
find -name "*.php" -type f -exec chown $USER:$USER {} +
|
||||||
|
find -name ".env" -type f -exec chown $USER:$USER {} +
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
echo "Permissions for $domain have been successfully updated."
|
||||||
|
|
||||||
|
exit 0
|
41
bin/v-fix-website-permissions-for-all-websites
Normal file
41
bin/v-fix-website-permissions-for-all-websites
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: fix website permissions for all websites
|
||||||
|
# options:
|
||||||
|
#
|
||||||
|
# The command is used for fixing website permissions for all websites on the server.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Importing system variables
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
|
||||||
|
if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
|
for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
|
||||||
|
/usr/local/vesta/bin/v-fix-website-permissions $domain $user
|
||||||
|
echo "--------------------------------"
|
||||||
|
done
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
|
exit
|
110
bin/v-fix-wordpress-core
Normal file
110
bin/v-fix-wordpress-core
Normal file
|
@ -0,0 +1,110 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: fix compromised wp-admin and wp-includes
|
||||||
|
# options: DOMAIN [CACHE_DIR]
|
||||||
|
#
|
||||||
|
# Replaces wp-admin and wp-includes with clean copies that match
|
||||||
|
# the WordPress core version detected on the site.
|
||||||
|
#
|
||||||
|
# Example:
|
||||||
|
# v-fix-wp-core example.com
|
||||||
|
# v-fix-wp-core example.com /srv/wp-cache
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable & Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Arguments
|
||||||
|
DOMAIN="$1"
|
||||||
|
CACHE_DIR="${2-/srv/wp-cache}" # default cache location
|
||||||
|
|
||||||
|
QUARANTINE_DIR="/srv/wp-quarantine"
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
source $VESTA/conf/vesta.conf
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
check_args '1' "$#" 'DOMAIN [CACHE_DIR]'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
TMP_DIR="$(mktemp -d /tmp/wpfix.XXXXXX)" # temp workspace
|
||||||
|
trap 'rm -rf "$TMP_DIR"' EXIT
|
||||||
|
|
||||||
|
# 1etermine WP version
|
||||||
|
WP_VERSION="$(/usr/local/vesta/bin/v-run-wp-cli "$DOMAIN" core version | tr -d '[:space:]')"
|
||||||
|
check_result $? "cannot detect WP version" > /dev/null
|
||||||
|
if [ -z "$WP_VERSION" ]; then
|
||||||
|
check_result 1 "empty WP version string"
|
||||||
|
fi
|
||||||
|
echo "Detected WordPress version $WP_VERSION"
|
||||||
|
|
||||||
|
# 2ind site owner and path
|
||||||
|
USER="$(/usr/local/vesta/bin/v-search-domain-owner "$DOMAIN")"
|
||||||
|
check_result $? "cannot find domain owner" > /dev/null
|
||||||
|
SITE_PATH="/home/$USER/web/$DOMAIN/public_html"
|
||||||
|
if [ ! -d "$SITE_PATH" ]; then
|
||||||
|
check_result 1 "site path $SITE_PATH does not exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ensure cached core is present
|
||||||
|
CACHE_PATH="$CACHE_DIR/$WP_VERSION"
|
||||||
|
if [ ! -d "$CACHE_PATH/wp-admin" ] || [ ! -d "$CACHE_PATH/wp-includes" ]; then
|
||||||
|
echo "Cache for $WP_VERSION missing, downloading ZIP..."
|
||||||
|
|
||||||
|
mkdir -p "$CACHE_PATH"
|
||||||
|
ZIP_URL="https://wordpress.org/wordpress-${WP_VERSION}.zip"
|
||||||
|
ZIP_FILE="$TMP_DIR/wp.zip"
|
||||||
|
|
||||||
|
curl -fSL "$ZIP_URL" -o "$ZIP_FILE"
|
||||||
|
check_result $? "download failed" > /dev/null
|
||||||
|
|
||||||
|
unzip -q "$ZIP_FILE" -d "$TMP_DIR"
|
||||||
|
check_result $? "unzip failed" > /dev/null
|
||||||
|
|
||||||
|
mv "$TMP_DIR/wordpress/wp-admin" "$CACHE_PATH/"
|
||||||
|
mv "$TMP_DIR/wordpress/wp-includes" "$CACHE_PATH/"
|
||||||
|
cp "$TMP_DIR/wordpress"/*.php "$CACHE_PATH/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# backup current core folders
|
||||||
|
TIMESTAMP="$(date +%Y%m%d%H%M%S)"
|
||||||
|
BACKUP_DIR="$QUARANTINE_DIR/$DOMAIN/backup-core-$TIMESTAMP"
|
||||||
|
mkdir -p "$BACKUP_DIR"
|
||||||
|
mv "$SITE_PATH/wp-admin" "$BACKUP_DIR/"
|
||||||
|
mv "$SITE_PATH/wp-includes" "$BACKUP_DIR/"
|
||||||
|
|
||||||
|
for f in "$SITE_PATH"/*.php; do
|
||||||
|
[[ $(basename "$f") == "wp-config.php" ]] && continue
|
||||||
|
mv "$f" "$BACKUP_DIR/"
|
||||||
|
done
|
||||||
|
if [ -f "$SITE_PATH/.user.ini" ]; then
|
||||||
|
mv "$SITE_PATH/.user.ini" "$BACKUP_DIR/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# chown -R www-data:www-data "$BACKUP_DIR"
|
||||||
|
check_result $? "backup failed" > /dev/null
|
||||||
|
echo "Old core folders moved to $BACKUP_DIR"
|
||||||
|
|
||||||
|
# deploy clean core
|
||||||
|
rsync -a --delete "$CACHE_PATH/wp-admin/" "$SITE_PATH/wp-admin/"
|
||||||
|
rsync -a --delete "$CACHE_PATH/wp-includes/" "$SITE_PATH/wp-includes/"
|
||||||
|
check_result $? "rsync failed" > /dev/null
|
||||||
|
|
||||||
|
for corephp in "$CACHE_PATH"/*.php; do
|
||||||
|
base=$(basename "$corephp")
|
||||||
|
[ "$base" = "wp-config.php" ] && continue
|
||||||
|
rsync -a "$corephp" "$SITE_PATH/$base"
|
||||||
|
done
|
||||||
|
|
||||||
|
# fix permissions
|
||||||
|
SKIP_OWNERSHIP_CHECK=1 /usr/local/vesta/bin/v-fix-website-permissions $DOMAIN
|
||||||
|
# chown -R www-data:www-data "$BACKUP_DIR"
|
||||||
|
|
||||||
|
echo "Done, core WP files, wp-admin and wp-includes replaced for $DOMAIN"
|
||||||
|
exit
|
70
bin/v-get-dns-config
Normal file
70
bin/v-get-dns-config
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Get domain DNS config.db file content
|
||||||
|
# options: DOMAIN
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
SILENT_MODE=1
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
domain=$1
|
||||||
|
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
USER=$user
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
source /usr/local/vesta/func/domain.sh
|
||||||
|
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
check_result $E_NOTEXIST "domain $domain doesn't exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
check_args '1' "$#" 'DOMAIN'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user" ]; then
|
||||||
|
# echo "User doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user/web/$domain/public_html" ]; then
|
||||||
|
# echo "Domain doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
DNS_FILE="/home/$user/conf/dns/$domain.db"
|
||||||
|
|
||||||
|
if [ -f "$DNS_FILE" ]; then
|
||||||
|
cat "$DNS_FILE"
|
||||||
|
else
|
||||||
|
echo "DNS configuration file for $domain does not exist."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit 0;
|
44
bin/v-get-wp-cli
Normal file
44
bin/v-get-wp-cli
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Download WP CLI
|
||||||
|
# options: NONE
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
if [ ! -f "/usr/local/bin/composer" ]; then
|
||||||
|
echo "= Composer is not installed. Installing..."
|
||||||
|
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
|
||||||
|
php composer-setup.php --install-dir=/usr/local/bin --filename=composer
|
||||||
|
php -r "unlink('composer-setup.php');"
|
||||||
|
echo "= Composer installed successfully."
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -d "/usr/local/bin/wp-cli" ]; then
|
||||||
|
echo "= Removing old WP CLI..."
|
||||||
|
rm -rf /usr/local/bin/wp-cli
|
||||||
|
fi
|
||||||
|
|
||||||
|
cd /usr/local/bin
|
||||||
|
git clone https://github.com/wp-cli/wp-cli.git
|
||||||
|
|
||||||
|
chown -R www-data:www-data wp-cli
|
||||||
|
|
||||||
|
cd wp-cli/
|
||||||
|
sudo -H -u www-data composer install
|
||||||
|
|
||||||
|
# Fix terminal columns issue for WP CLI
|
||||||
|
/usr/local/vesta/bin/v-sed '$columns = 80;' "if (file_exists('/usr/local/bin/wp-cli/COLUMNS')) \$columns=intval(file_get_contents('/usr/local/bin/wp-cli/COLUMNS')); else \$columns = 80;" '/usr/local/bin/wp-cli/vendor/wp-cli/php-cli-tools/lib/cli/Shell.php'
|
||||||
|
|
||||||
|
echo "= WP CLI installed successfully."
|
||||||
|
|
||||||
|
exit 0;
|
27
bin/v-grep
Normal file
27
bin/v-grep
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: calling myvesta_grep PHP function
|
||||||
|
# options: PARAMETERS
|
||||||
|
#
|
||||||
|
# The function is calling myVesta PHP replacement for GNU 'grep' command (but without regular expression)
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$1" == "--stdin" ] && [ -p /dev/stdin ]; then
|
||||||
|
STDIN=$(cat -)
|
||||||
|
if [ ! -z "$STDIN" ]; then
|
||||||
|
shift;
|
||||||
|
echo "$STDIN" | php /usr/local/vesta/func/bash-to-php-interpreter.php '--stdin' 'myvesta_grep' "$@"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "--stdin" ]; then
|
||||||
|
shift;
|
||||||
|
php /usr/local/vesta/func/bash-to-php-interpreter.php '--stdin' 'myvesta_grep' "$@"
|
||||||
|
else
|
||||||
|
php /usr/local/vesta/func/bash-to-php-interpreter.php 'myvesta_grep' "$@"
|
||||||
|
fi
|
||||||
|
exit $?
|
|
@ -157,9 +157,15 @@ for sk_dbr in $sk_db_list
|
||||||
echo " Create and restore ${sk_dbr} "
|
echo " Create and restore ${sk_dbr} "
|
||||||
sed -i "s/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/g" mysql/${sk_dbr}.create
|
sed -i "s/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/g" mysql/${sk_dbr}.create
|
||||||
sed -i "s/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g" mysql/${sk_dbr}.create
|
sed -i "s/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g" mysql/${sk_dbr}.create
|
||||||
|
if grep -q ' enable the sandbox mode ' mysql/${sk_dbr}.create; then
|
||||||
|
v-sed '/*!999999\- enable the sandbox mode */' '' mysql/${sk_dbr}.create
|
||||||
|
fi
|
||||||
mysql < mysql/${sk_dbr}.create
|
mysql < mysql/${sk_dbr}.create
|
||||||
sed -i "s/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/g" mysql/${sk_dbr}.sql
|
sed -i "s/utf8mb4_unicode_520_ci/utf8mb4_unicode_ci/g" mysql/${sk_dbr}.sql
|
||||||
sed -i "s/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g" mysql/${sk_dbr}.sql
|
sed -i "s/utf8mb4_0900_ai_ci/utf8mb4_unicode_ci/g" mysql/${sk_dbr}.sql
|
||||||
|
if grep -q ' enable the sandbox mode ' mysql/${sk_dbr}.sql; then
|
||||||
|
v-sed '/*!999999\- enable the sandbox mode */' '' mysql/${sk_dbr}.sql
|
||||||
|
fi
|
||||||
mysql ${sk_dbr} < mysql/${sk_dbr}.sql
|
mysql ${sk_dbr} < mysql/${sk_dbr}.sql
|
||||||
else
|
else
|
||||||
echo "Error: Cant restore database $sk_dbr alredy exists in mysql server"
|
echo "Error: Cant restore database $sk_dbr alredy exists in mysql server"
|
||||||
|
@ -269,28 +275,29 @@ cd $sk_mdir
|
||||||
for sk_maild in $(ls -1)
|
for sk_maild in $(ls -1)
|
||||||
do
|
do
|
||||||
if [[ "$sk_maild" != "cur" && "$sk_maild" != "new" && "$sk_maild" != "tmp" ]]; then
|
if [[ "$sk_maild" != "cur" && "$sk_maild" != "new" && "$sk_maild" != "tmp" ]]; then
|
||||||
if [ -d "$sk_maild" ]; then
|
if [ -d "$sk_maild" ]; then
|
||||||
for sk_mail_account in $(ls $sk_maild/)
|
for sk_mail_account in $(ls $sk_maild/)
|
||||||
do
|
do
|
||||||
|
echo "Create and restore mail account: $sk_mail_account@$sk_maild"
|
||||||
echo "Create and restore mail account: $sk_mail_account@$sk_maild"
|
sk_mail_pass1=$(generate_password)
|
||||||
sk_mail_pass1=$(generate_password)
|
/usr/local/vesta/bin/v-add-mail-account $sk_cp_user $sk_maild $sk_mail_account $sk_mail_pass1
|
||||||
/usr/local/vesta/bin/v-add-mail-account $sk_cp_user $sk_maild $sk_mail_account $sk_mail_pass1
|
mv ${sk_maild}/${sk_mail_account} /home/${sk_cp_user}/mail/${sk_maild}
|
||||||
mv ${sk_maild}/${sk_mail_account} /home/${sk_cp_user}/mail/${sk_maild}
|
chown ${sk_cp_user}:mail -R /home/${sk_cp_user}/mail/${sk_maild}
|
||||||
chown ${sk_cp_user}:mail -R /home/${sk_cp_user}/mail/${sk_maild}
|
find /home/${sk_cp_user}/mail/${sk_maild} -type f -name 'dovecot*' -delete
|
||||||
find /home/${sk_cp_user}/mail/${sk_maild} -type f -name 'dovecot*' -delete
|
if [ -f "${sk_importer_in}/homedir/etc/${sk_maild}/shadow" ]; then
|
||||||
# echo "${sk_mail_account}@${sk_maild} | $sk_mail_pass1" >> /root/sk_mail_password_${sk_cp_user}-${sk_cod}
|
echo "Set password for ${sk_mail_account}@${sk_maild}"
|
||||||
echo "Set password for ${sk_mail_account}@${sk_maild}"
|
pass=$(grep "^${sk_mail_account}:" ${sk_importer_in}/homedir/etc/${sk_maild}/shadow | awk -F ":" '{print $2}')
|
||||||
pass=$(grep "^${sk_mail_account}:" ${sk_importer_in}/homedir/etc/${sk_maild}/shadow | awk -F ":" '{print $2}')
|
newline="${sk_mail_account}:{SHA512-CRYPT}$pass:${sk_cp_user}:mail::/home/${sk_cp_user}:0"
|
||||||
newline="${sk_mail_account}:{SHA512-CRYPT}$pass:${sk_cp_user}:mail::/home/${sk_cp_user}:0"
|
newline2="ACCOUNT='${sk_mail_account}' ALIAS='' AUTOREPLY='no' FWD='' FWD_ONLY='' MD5='{SHA512-CRYPT}$pass' QUOTA='unlimited' U_DISK='0' SUSPENDED='no' TIME='$time' DATE='$date'"
|
||||||
newline2="ACCOUNT='${sk_mail_account}' ALIAS='' AUTOREPLY='no' FWD='' FWD_ONLY='' MD5='{SHA512-CRYPT}$pass' QUOTA='unlimited' U_DISK='0' SUSPENDED='no' TIME='$time' DATE='$date'"
|
escaped=$(printf '%s\n' "$newline" | sed -e 's/[\/&]/\\&/g')
|
||||||
# echo $newline
|
escaped2=$(printf '%s\n' "$newline2" | sed -e 's/[\/&]/\\&/g')
|
||||||
escaped=$(printf '%s\n' "$newline" | sed -e 's/[\/&]/\\&/g')
|
sed -i "s/^${sk_mail_account}:.*/$escaped/g" /home/${sk_cp_user}/conf/mail/${sk_maild}/passwd
|
||||||
escaped2=$(printf '%s\n' "$newline2" | sed -e 's/[\/&]/\\&/g')
|
sed -i "s/^ACCOUNT='${sk_mail_account}.*/$escaped2/g" /usr/local/vesta/data/users/${sk_cp_user}/mail/${sk_maild}.conf
|
||||||
sed -i "s/^${sk_mail_account}:.*/$escaped/g" /home/${sk_cp_user}/conf/mail/${sk_maild}/passwd
|
else
|
||||||
sed -i "s/^ACCOUNT='${sk_mail_account}.*/$escaped2/g" /usr/local/vesta/data/users/${sk_cp_user}/mail/${sk_maild}.conf
|
echo "${sk_mail_account}@${sk_maild} | $sk_mail_pass1" >> /root/sk_mail_password_${sk_cp_user}-${sk_cod}
|
||||||
done
|
fi
|
||||||
fi
|
done
|
||||||
|
fi
|
||||||
#else
|
#else
|
||||||
# this only detect default dirs account new, cur, tmp etc
|
# this only detect default dirs account new, cur, tmp etc
|
||||||
# maybe can do something with this, but on most cpanel default account have only spam.
|
# maybe can do something with this, but on most cpanel default account have only spam.
|
||||||
|
@ -367,7 +374,9 @@ tput setaf 4
|
||||||
echo "##############################"
|
echo "##############################"
|
||||||
echo "cPanel Backup restored"
|
echo "cPanel Backup restored"
|
||||||
echo "Review your content and report any fail"
|
echo "Review your content and report any fail"
|
||||||
# echo "I reset mail password not posible restore it yet."
|
if [ -f "/root/sk_mail_password_${sk_cp_user}-${sk_cod}" ]; then
|
||||||
# echo "Check your new passwords runing: cat /root/sk_mail_password_${sk_cp_user}-${sk_cod}"
|
echo "I reset mail password not posible restore it yet."
|
||||||
|
echo "Check your new passwords runing: cat /root/sk_mail_password_${sk_cp_user}-${sk_cod}"
|
||||||
|
fi
|
||||||
echo "##############################"
|
echo "##############################"
|
||||||
tput sgr0
|
tput sgr0
|
||||||
|
|
|
@ -52,6 +52,12 @@ fi
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [ -f "/home/$user/conf/web/ssl.$domain.crt" ]; then
|
||||||
|
/usr/local/vesta/bin/v-delete-web-domain-ssl "$user" "$domain"
|
||||||
|
fi
|
||||||
|
|
||||||
|
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
|
|
||||||
email="info@$domain"
|
email="info@$domain"
|
||||||
|
|
||||||
TMPLOC="/home/$user/tmp/$domain"
|
TMPLOC="/home/$user/tmp/$domain"
|
||||||
|
@ -62,8 +68,13 @@ mkdir $TMPLOC
|
||||||
|
|
||||||
# Parsing certificate file
|
# Parsing certificate file
|
||||||
crt_end=$(grep -n "END CERTIFICATE-" $TMPLOC/vst.pem |cut -f 1 -d:)
|
crt_end=$(grep -n "END CERTIFICATE-" $TMPLOC/vst.pem |cut -f 1 -d:)
|
||||||
key_start=$(grep -n "BEGIN RSA" $TMPLOC/vst.pem |cut -f 1 -d:)
|
if [ "$release" -lt 12 ]; then
|
||||||
key_end=$(grep -n "END RSA" $TMPLOC/vst.pem |cut -f 1 -d:)
|
key_start=$(grep -n "BEGIN RSA" $TMPLOC/vst.pem |cut -f 1 -d:)
|
||||||
|
key_end=$(grep -n "END RSA" $TMPLOC/vst.pem |cut -f 1 -d:)
|
||||||
|
else
|
||||||
|
key_start=$(grep -n "BEGIN PRIVATE KEY" $TMPLOC/vst.pem |cut -f 1 -d:)
|
||||||
|
key_end=$(grep -n "END PRIVATE KEY" $TMPLOC/vst.pem |cut -f 1 -d:)
|
||||||
|
fi
|
||||||
|
|
||||||
# Adding SSL certificate
|
# Adding SSL certificate
|
||||||
cd $TMPLOC
|
cd $TMPLOC
|
||||||
|
|
|
@ -95,21 +95,37 @@ PASSWDDB=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 8 | head -n 1)
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
PROTOCOL='http'
|
PROTOCOL='https'
|
||||||
if [ -z "$SKIP_LE" ]; then
|
|
||||||
if [ ! -f "/home/$user/conf/web/ssl.$domain.ca" ]; then
|
if [ ! -f "/home/$user/conf/web/ssl.$domain.ca" ]; then
|
||||||
/usr/local/vesta/bin/v-add-letsencrypt-domain "$user" "$domain" "www.$domain" "yes"
|
echo "== Trying to install LetsEncrypt for domain $domain"
|
||||||
fi
|
/usr/local/vesta/bin/v-add-letsencrypt-domain "$user" "$domain" "www.$domain" "yes"
|
||||||
else
|
|
||||||
PROTOCOL='https'
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -f "/home/$user/conf/web/ssl.$domain.ca" ] || [ ! -z "$SKIP_LE" ]; then
|
if [ ! -z "$FORCE_HTTP" ]; then
|
||||||
PROTOCOL='https'
|
# Switch to http:// only if --FORCE_HTTP parameter is set
|
||||||
if [ -f "/usr/local/vesta/data/templates/web/nginx/force-https.stpl" ]; then
|
echo "== Force http://"
|
||||||
|
PROTOCOL='http'
|
||||||
|
fi
|
||||||
|
|
||||||
|
TPL_CHANGED=0;
|
||||||
|
|
||||||
|
if [ "$PROTOCOL" = "https" ]; then
|
||||||
|
if [ -f "/usr/local/vesta/data/templates/web/nginx/force-https-firewall-wordpress.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
|
||||||
|
TPL_CHANGED=1;
|
||||||
|
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "force-https-firewall-wordpress" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
|
||||||
|
fi
|
||||||
|
if [ -f "/usr/local/vesta/data/templates/web/nginx/force-https.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
|
||||||
|
TPL_CHANGED=1;
|
||||||
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "force-https" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
|
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "force-https" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
if [ "$PROTOCOL" = "http" ]; then
|
||||||
|
if [ -f "/usr/local/vesta/data/templates/web/nginx/hosting-firewall-wordpress.stpl" ] && [ $TPL_CHANGED -eq 0 ]; then
|
||||||
|
TPL_CHANGED=1;
|
||||||
|
/usr/local/vesta/bin/v-change-web-domain-proxy-tpl "$user" "$domain" "hosting-firewall-wordpress" "jpeg,jpg,png,gif,bmp,ico,svg,tif,tiff,css,js,ttf,otf,webp,txt,csv,rtf,doc,docx,xls,xlsx,ppt,pptx,odf,odp,ods,odt,pdf,psd,ai,eot,eps,ps,zip,tar,tgz,gz,rar,bz2,7z,aac,m4a,mp3,mp4,ogg,wav,wma,3gp,avi,flv,m4v,mkv,mov,mpeg,mpg,wmv,exe,iso,dmg,swf,woff,woff2" "yes"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
/usr/local/vesta/bin/v-add-database "$user" "$DBUSERSUF" "$DBUSERSUF" "$PASSWDDB" "mysql"
|
/usr/local/vesta/bin/v-add-database "$user" "$DBUSERSUF" "$DBUSERSUF" "$PASSWDDB" "mysql"
|
||||||
|
|
||||||
|
@ -135,11 +151,11 @@ sudo -H -u$user wp core install --url="$domain" --title="$domain" --admin_user="
|
||||||
mysql -u$DBUSER -p$PASSWDDB -e "USE $DBUSER; update wp_options set option_value = '$PROTOCOL://$domain' where option_name = 'siteurl'; update wp_options set option_value = '$PROTOCOL://$domain' where option_name = 'home';"
|
mysql -u$DBUSER -p$PASSWDDB -e "USE $DBUSER; update wp_options set option_value = '$PROTOCOL://$domain' where option_name = 'siteurl'; update wp_options set option_value = '$PROTOCOL://$domain' where option_name = 'home';"
|
||||||
|
|
||||||
echo "================================================================="
|
echo "================================================================="
|
||||||
echo "Installation is complete. Your username/password is listed below."
|
echo "Your WordPress installation is complete."
|
||||||
echo ""
|
echo ""
|
||||||
echo "Site: $PROTOCOL://$domain/"
|
echo "Website URL: $PROTOCOL://$domain/"
|
||||||
echo ""
|
echo ""
|
||||||
echo "Login: $PROTOCOL://$domain/wp-admin/"
|
echo "WordPress admin login: $PROTOCOL://$domain/wp-admin/"
|
||||||
echo "Username: $wpadmin"
|
echo "Username: $wpadmin"
|
||||||
echo "Password: $password"
|
echo "Password: $password"
|
||||||
echo ""
|
echo ""
|
||||||
|
|
76
bin/v-list-php
Normal file
76
bin/v-list-php
Normal file
|
@ -0,0 +1,76 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: list of installed php versions
|
||||||
|
# options: [FORMAT]
|
||||||
|
#
|
||||||
|
# The function for obtaining the list of installed PHP versions.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
format=${1-shell}
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
# JSON list function
|
||||||
|
json_list() {
|
||||||
|
counter=$(echo "$phpversions" | wc -l)
|
||||||
|
i=1
|
||||||
|
echo '['
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
if [ "$i" -lt "$counter" ]; then
|
||||||
|
echo -e "\t\"$phpversion\","
|
||||||
|
else
|
||||||
|
echo -e "\t\"$phpversion\""
|
||||||
|
fi
|
||||||
|
(( ++i))
|
||||||
|
done
|
||||||
|
echo "]"
|
||||||
|
}
|
||||||
|
|
||||||
|
# shell list function
|
||||||
|
shell_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# PLAIN list function
|
||||||
|
plain_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# CSV list function
|
||||||
|
csv_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Obtaining the list of installed PHP-FPM versions
|
||||||
|
phpversions=$(find /etc/php/ -type d -name 'fpm' | sed "s|/etc/php/||" | sed "s|/fpm||" | sort)
|
||||||
|
|
||||||
|
# Listing data
|
||||||
|
case $format in
|
||||||
|
json) json_list ;;
|
||||||
|
plain) plain_list ;;
|
||||||
|
csv) csv_list ;;
|
||||||
|
shell) shell_list ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit
|
91
bin/v-list-php-apache
Normal file
91
bin/v-list-php-apache
Normal file
|
@ -0,0 +1,91 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: list of installed php versions that have Apache template.
|
||||||
|
# options: [FORMAT]
|
||||||
|
#
|
||||||
|
# The function obtains the list of installed PHP versions that have Apache template.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
format=${1-shell}
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
# JSON list function
|
||||||
|
json_list() {
|
||||||
|
counter=$(echo "$phpversions" | wc -l)
|
||||||
|
i=1
|
||||||
|
echo '['
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
if [ "$i" -lt "$counter" ]; then
|
||||||
|
echo -e "\t\"$phpversion\","
|
||||||
|
else
|
||||||
|
echo -e "\t\"$phpversion\""
|
||||||
|
fi
|
||||||
|
(( ++i))
|
||||||
|
done
|
||||||
|
echo "]"
|
||||||
|
}
|
||||||
|
|
||||||
|
# shell list function
|
||||||
|
shell_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# PLAIN list function
|
||||||
|
plain_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
# CSV list function
|
||||||
|
csv_list() {
|
||||||
|
for phpversion in $phpversions; do
|
||||||
|
echo "$phpversion"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
echo_phpversions_list() {
|
||||||
|
for element in "${phpversions_list[@]}"; do
|
||||||
|
echo "$element"
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Obtaining the list of installed PHP-FPM versions
|
||||||
|
fpmphpversions=$(/usr/local/vesta/bin/v-list-php)
|
||||||
|
|
||||||
|
for phpversion in $fpmphpversions; do
|
||||||
|
phpversiontpl=${phpversion//./}
|
||||||
|
tpl="/usr/local/vesta/data/templates/web/apache2/PHP-FPM-$phpversiontpl.tpl"
|
||||||
|
if [ -f "$tpl" ]; then
|
||||||
|
phpversions_list+=("$phpversion")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
phpversions=$(echo_phpversions_list)
|
||||||
|
|
||||||
|
# Listing data
|
||||||
|
case $format in
|
||||||
|
json) json_list ;;
|
||||||
|
plain) plain_list ;;
|
||||||
|
csv) csv_list ;;
|
||||||
|
shell) shell_list ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit
|
|
@ -54,7 +54,8 @@ json_list() {
|
||||||
"SOFTACULOUS": "'$SOFTACULOUS'",
|
"SOFTACULOUS": "'$SOFTACULOUS'",
|
||||||
"MAX_DBUSER_LEN": "'$MAX_DBUSER_LEN'",
|
"MAX_DBUSER_LEN": "'$MAX_DBUSER_LEN'",
|
||||||
"MAIL_CERTIFICATE": "'$MAIL_CERTIFICATE'",
|
"MAIL_CERTIFICATE": "'$MAIL_CERTIFICATE'",
|
||||||
"VESTA_CERTIFICATE": "'$VESTA_CERTIFICATE'"
|
"VESTA_CERTIFICATE": "'$VESTA_CERTIFICATE'",
|
||||||
|
"DISABLE_IP_CHECK": "'$DISABLE_IP_CHECK'"
|
||||||
}
|
}
|
||||||
}'
|
}'
|
||||||
}
|
}
|
||||||
|
|
|
@ -297,7 +297,11 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB_SYSTEM" != 'remote' ]; then
|
||||||
if [ "$service" = 'mysql' ]; then
|
if [ "$service" = 'mysql' ]; then
|
||||||
proc_name='mysqld'
|
proc_name='mysqld'
|
||||||
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
if [ "$release" -eq 11 ] && [ ! -f "/etc/apt/sources.list.d/mysql.list" ]; then
|
if [ "$release" -gt 10 ] && [ ! -f "/etc/apt/sources.list.d/mysql.list" ]; then
|
||||||
|
service='mariadb'
|
||||||
|
proc_name='mariadbd'
|
||||||
|
fi
|
||||||
|
if [ -f "/etc/apt/sources.list.d/mariadb.list" ]; then
|
||||||
service='mariadb'
|
service='mariadb'
|
||||||
proc_name='mariadbd'
|
proc_name='mariadbd'
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -12,6 +12,7 @@
|
||||||
# Argument definition
|
# Argument definition
|
||||||
user=$1
|
user=$1
|
||||||
format=${2-shell}
|
format=${2-shell}
|
||||||
|
limit=${3-300}
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
@ -34,6 +35,9 @@ json_list() {
|
||||||
"TIME": "'$TIME'",
|
"TIME": "'$TIME'",
|
||||||
"DATE": "'$DATE'"
|
"DATE": "'$DATE'"
|
||||||
}'
|
}'
|
||||||
|
if [ "$limit" -gt 0 ] && [ "$i" = "$limit" ]; then
|
||||||
|
break;
|
||||||
|
fi
|
||||||
if [ "$i" -lt "$objects" ]; then
|
if [ "$i" -lt "$objects" ]; then
|
||||||
echo ','
|
echo ','
|
||||||
else
|
else
|
||||||
|
@ -83,7 +87,7 @@ csv_list() {
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
check_args '1' "$#" 'USER [FORMAT]'
|
check_args '1' "$#" 'USER [FORMAT] [LIMIT]'
|
||||||
is_format_valid 'user'
|
is_format_valid 'user'
|
||||||
is_object_valid 'user' 'USER' "$user"
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
|
||||||
|
@ -93,7 +97,7 @@ is_object_valid 'user' 'USER' "$user"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Parsing history log
|
# Parsing history log
|
||||||
logs=$(tail -n 300 $USER_DATA/history.log 2>/dev/null)
|
logs=$(tail -n $limit $USER_DATA/history.log | tac)
|
||||||
|
|
||||||
case $format in
|
case $format in
|
||||||
json) json_list ;;
|
json) json_list ;;
|
||||||
|
|
14
bin/v-make-main-apache-log
Normal file
14
bin/v-make-main-apache-log
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
touch /var/log/apache2/time.log
|
||||||
|
# truncate -s 0 /var/log/apache2/time.log
|
||||||
|
chmod 0640 /var/log/apache2/time.log
|
||||||
|
chown root:adm /var/log/apache2/time.log
|
||||||
|
find /home/*/conf/web/ -type f \( -name "apache2.conf" -or -name "sapache2.conf" -or -name "*.apache2.conf" -or -name "*.apache2.ssl.conf" \) -exec grep -L "time\.log" {} \; | xargs sed -i 's|ServerName |CustomLog /var/log/apache2/time.log time\n ServerName |g'
|
||||||
|
find /usr/local/vesta/data/templates/web/apache2 -type f \( -name "*.tpl" -or -name "*.stpl" \) -exec grep -L "time\.log" {} \; | xargs sed -i 's|ServerName |CustomLog /var/log/apache2/time.log time\n ServerName |g'
|
||||||
|
if ! /usr/local/vesta/bin/v-grep 'LogFormat "%t %v %a %D %r %>s \"%{User-Agent}i\"" time' '/etc/apache2/apache2.conf' '-q'; then
|
||||||
|
sed -i 's|LogFormat "%b" bytes|LogFormat "%b" bytes\nLogFormat "%t %v %a %D %r %>s \\\"%{User-Agent}i\\\" pid=%P" time|g' /etc/apache2/apache2.conf
|
||||||
|
fi
|
||||||
|
systemctl restart apache2
|
||||||
|
|
||||||
|
wget -nv http://dl.myvestacp.com/vesta/apache_requests_analyzer/analyze-traffic.php -O /root/analyze-traffic.php
|
|
@ -1,4 +1,4 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# info: add new ip and makes email to be sent via that IP only for SMTP authenticated users
|
# info: add new ip and makes email to be sent via that IP only for SMTP authenticated users
|
||||||
# options: MAIL_HOSTNAME MAIL_IP
|
# options: MAIL_HOSTNAME MAIL_IP
|
||||||
|
@ -45,7 +45,7 @@ is_domain_format_valid "$MAIL_HOSTNAME"
|
||||||
is_ip_format_valid "$MAIL_IP"
|
is_ip_format_valid "$MAIL_IP"
|
||||||
|
|
||||||
HOST_USER=$($VESTA/bin/v-search-domain-owner "$HOSTNAME")
|
HOST_USER=$($VESTA/bin/v-search-domain-owner "$HOSTNAME")
|
||||||
if [ -z "$HOST_USER" ]; then
|
if [ -z "$HOST_USER" ]; then
|
||||||
echo "Error: hostname $HOSTNAME is not created as web domain"
|
echo "Error: hostname $HOSTNAME is not created as web domain"
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
@ -138,7 +138,18 @@ check_grep=$(grep -c 'smtp_active_hostname' /etc/exim4/exim4.conf.template)
|
||||||
if [ "$check_grep" -eq 0 ]; then
|
if [ "$check_grep" -eq 0 ]; then
|
||||||
echo "=== patching exim4.conf.template"
|
echo "=== patching exim4.conf.template"
|
||||||
mv /etc/exim4/exim4.conf.template /etc/exim4/exim4.conf.template-backup
|
mv /etc/exim4/exim4.conf.template /etc/exim4/exim4.conf.template-backup
|
||||||
cp /usr/local/vesta/install/debian/11/exim/exim4.conf.template-RC /etc/exim4/exim4.conf.template
|
cp /usr/local/vesta/install/debian/12/exim/exim4.conf.template /etc/exim4/exim4.conf.template
|
||||||
|
|
||||||
|
eximversion=$(exim4 --version | grep '^Exim version ' | awk '{print $3}')
|
||||||
|
if (( $(echo "$eximversion < 4.96" | bc -l) )); then
|
||||||
|
cp /usr/local/vesta/install/debian/12/exim/exim4.conf.template.without-srs /etc/exim4/exim4.conf.template
|
||||||
|
sed -i "s|message_linelength_limit|#message_linelength_limit|g" /etc/exim4/exim4.conf.template
|
||||||
|
fi
|
||||||
|
|
||||||
|
if (( $(echo "$eximversion < 4.94" | bc -l) )); then
|
||||||
|
sed -i "s|smtputf8_advertise_hosts|#smtputf8_advertise_hosts|g" /etc/exim4/exim4.conf.template
|
||||||
|
fi
|
||||||
|
|
||||||
sed -i "s|FIRSTIP|$HOST_IP|g" /etc/exim4/exim4.conf.template
|
sed -i "s|FIRSTIP|$HOST_IP|g" /etc/exim4/exim4.conf.template
|
||||||
sed -i "s|SECONDIP|$MAIL_IP|g" /etc/exim4/exim4.conf.template
|
sed -i "s|SECONDIP|$MAIL_IP|g" /etc/exim4/exim4.conf.template
|
||||||
sed -i "s|FIRSTHOST|$HOSTNAME|g" /etc/exim4/exim4.conf.template
|
sed -i "s|FIRSTHOST|$HOSTNAME|g" /etc/exim4/exim4.conf.template
|
||||||
|
@ -148,6 +159,8 @@ if [ "$check_grep" -eq 0 ]; then
|
||||||
sed -i "s|#smtp_banner|smtp_banner|g" /etc/exim4/exim4.conf.template
|
sed -i "s|#smtp_banner|smtp_banner|g" /etc/exim4/exim4.conf.template
|
||||||
sed -i "s|#interface =|interface =|g" /etc/exim4/exim4.conf.template
|
sed -i "s|#interface =|interface =|g" /etc/exim4/exim4.conf.template
|
||||||
sed -i "s|#helo_data =|helo_data =|g" /etc/exim4/exim4.conf.template
|
sed -i "s|#helo_data =|helo_data =|g" /etc/exim4/exim4.conf.template
|
||||||
|
/usr/local/vesta/bin/v-sed 'tls_certificate = /usr/local/vesta/ssl/certificate.crt' 'tls_certificate = /usr/local/vesta/ssl/$received_ip_address.crt' '/etc/exim4/exim4.conf.template'
|
||||||
|
/usr/local/vesta/bin/v-sed 'tls_privatekey = /usr/local/vesta/ssl/certificate.key' 'tls_privatekey = /usr/local/vesta/ssl/$received_ip_address.key' '/etc/exim4/exim4.conf.template'
|
||||||
touch /etc/exim4/limit_per_email_account_max_sent_emails_per_hour
|
touch /etc/exim4/limit_per_email_account_max_sent_emails_per_hour
|
||||||
touch /etc/exim4/limit_per_email_account_max_recipients
|
touch /etc/exim4/limit_per_email_account_max_recipients
|
||||||
touch /etc/exim4/limit_per_hosting_account_max_sent_emails_per_hour
|
touch /etc/exim4/limit_per_hosting_account_max_sent_emails_per_hour
|
||||||
|
@ -166,9 +179,10 @@ if [ "$check_grep" -eq 0 ]; then
|
||||||
fi
|
fi
|
||||||
systemctl restart exim4
|
systemctl restart exim4
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
|
systemctl status exim4
|
||||||
cp /etc/exim4/exim4.conf.template-backup /etc/exim4/exim4.conf.template
|
cp /etc/exim4/exim4.conf.template-backup /etc/exim4/exim4.conf.template
|
||||||
systemctl restart exim4
|
systemctl restart exim4
|
||||||
echo "=== Patching failed, aborting"
|
echo "=== Patching failed, old exim conf returned, exim4 restarted again."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
echo "=== Patching successful"
|
echo "=== Patching successful"
|
||||||
|
|
|
@ -94,6 +94,8 @@ if [ "$DB_EXISTS" = "no" ]; then
|
||||||
exit 6
|
exit 6
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$FROM_DOMAIN")
|
||||||
|
|
||||||
# ----------- CHECK -------------
|
# ----------- CHECK -------------
|
||||||
|
|
||||||
FROM_REPLACE1="http://$FROM_DOMAIN"
|
FROM_REPLACE1="http://$FROM_DOMAIN"
|
||||||
|
@ -102,13 +104,13 @@ FROM_REPLACE2="http://www.$FROM_DOMAIN"
|
||||||
TO_REPLACE2="https://www.$FROM_DOMAIN"
|
TO_REPLACE2="https://www.$FROM_DOMAIN"
|
||||||
|
|
||||||
if [ $IT_IS_WP -eq 0 ]; then
|
if [ $IT_IS_WP -eq 0 ]; then
|
||||||
if [ ! -f "/root/Search-Replace-DB-master/srdb.cli.php" ]; then
|
if [ ! -f "/root/Search-Replace-DB/srdb.cli.php" ]; then
|
||||||
echo "Please download https://interconnectit.com/products/search-and-replace-for-wordpress-databases/ and extract to /root/Search-Replace-DB-master/"
|
if [ ! -f "/usr/bin/git" ]; then
|
||||||
exit 7
|
apt-get update > /dev/null 2>&1
|
||||||
fi
|
apt-get -y install git > /dev/null 2>&1
|
||||||
if [ ! -f "/usr/bin/php7.0" ]; then
|
fi
|
||||||
echo "Please download https://c.myvestacp.com/tools/multi-php-install.sh and install php 7.0"
|
cd /root
|
||||||
exit 8
|
git clone https://github.com/interconnectit/Search-Replace-DB.git
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
if [ ! -f "/usr/local/bin/wp" ]; then
|
if [ ! -f "/usr/local/bin/wp" ]; then
|
||||||
|
@ -164,15 +166,15 @@ grep -rl "$FROM_DOMAIN" $SITE_FOLDER | xargs sed -i "s#$FROM_REPLACE2#$TO_REPLAC
|
||||||
|
|
||||||
if [ $IT_IS_WP -eq 0 ]; then
|
if [ $IT_IS_WP -eq 0 ]; then
|
||||||
echo "=== Replacing $FROM_REPLACE1 to $TO_REPLACE1 in database $FROM_DATABASE_NAME"
|
echo "=== Replacing $FROM_REPLACE1 to $TO_REPLACE1 in database $FROM_DATABASE_NAME"
|
||||||
php7.0 /root/Search-Replace-DB-master/srdb.cli.php -h localhost -n "$FROM_DATABASE_NAME" -u "$FROM_DATABASE_USERNAME" -p "$FROM_DATABASE_PASSWORD" -s "$FROM_REPLACE1" -r "$TO_REPLACE1"
|
php /root/Search-Replace-DB/srdb.cli.php -h localhost -n "$FROM_DATABASE_NAME" -u "$FROM_DATABASE_USERNAME" -p "$FROM_DATABASE_PASSWORD" -s "$FROM_REPLACE1" -r "$TO_REPLACE1"
|
||||||
echo "=== Replacing $FROM_REPLACE2 to $TO_REPLACE2 in database $FROM_DATABASE_NAME"
|
echo "=== Replacing $FROM_REPLACE2 to $TO_REPLACE2 in database $FROM_DATABASE_NAME"
|
||||||
php7.0 /root/Search-Replace-DB-master/srdb.cli.php -h localhost -n "$FROM_DATABASE_NAME" -u "$FROM_DATABASE_USERNAME" -p "$FROM_DATABASE_PASSWORD" -s "$FROM_REPLACE2" -r "$TO_REPLACE2"
|
php /root/Search-Replace-DB/srdb.cli.php -h localhost -n "$FROM_DATABASE_NAME" -u "$FROM_DATABASE_USERNAME" -p "$FROM_DATABASE_PASSWORD" -s "$FROM_REPLACE2" -r "$TO_REPLACE2"
|
||||||
else
|
else
|
||||||
cd $SITE_FOLDER
|
cd $SITE_FOLDER
|
||||||
echo "=== Replacing $FROM_REPLACE1 to $TO_REPLACE1 in database $FROM_DATABASE_NAME"
|
echo "=== Replacing $FROM_REPLACE1 to $TO_REPLACE1 in database $FROM_DATABASE_NAME"
|
||||||
sudo -H -u$FROM_USER wp search-replace "$FROM_REPLACE1" "$TO_REPLACE1" --precise --all-tables --skip-columns=guid
|
sudo -H -u$FROM_USER /usr/bin/php$phpver /usr/local/bin/wp search-replace "$FROM_REPLACE1" "$TO_REPLACE1" --precise --all-tables --skip-columns=guid --skip-plugins=$(sudo -H -u$FROM_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
|
||||||
echo "=== Replacing $FROM_REPLACE2 to $TO_REPLACE2 in database $FROM_DATABASE_NAME"
|
echo "=== Replacing $FROM_REPLACE2 to $TO_REPLACE2 in database $FROM_DATABASE_NAME"
|
||||||
sudo -H -u$FROM_USER wp search-replace "$FROM_REPLACE2" "$TO_REPLACE2" --precise --all-tables --skip-columns=guid
|
sudo -H -u$FROM_USER /usr/bin/php$phpver /usr/local/bin/wp search-replace "$FROM_REPLACE2" "$TO_REPLACE2" --precise --all-tables --skip-columns=guid --skip-plugins=$(sudo -H -u$FROM_USER /usr/bin/php$phpver /usr/local/bin/wp plugin list --field=name | tr '\n' ',') --skip-themes;
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "===== DONE ===="
|
echo "===== DONE ===="
|
||||||
|
|
|
@ -40,6 +40,10 @@ if [ "$owner" = "$user" ]; then
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
USER_DATA=$VESTA/data/users/$owner
|
||||||
|
is_object_unsuspended 'user' 'USER' "$owner"
|
||||||
|
USER_DATA=$VESTA/data/users/$user
|
||||||
|
|
||||||
USER_TO=$user
|
USER_TO=$user
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
@ -84,6 +88,56 @@ if [ $? -ne 0 ]; then
|
||||||
RET=$E_NOTEXIST
|
RET=$E_NOTEXIST
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Update Wordfence WAF Path #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
filepath="/home/USER_TO/web/$domain/public_html/.user.ini"
|
||||||
|
filename=$(basename $filepath)
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if [ -f "$filepath" ]; then
|
||||||
|
echo "Updating $filename with new user path..."
|
||||||
|
|
||||||
|
# Temporary file for modification
|
||||||
|
tmp_file=$(mktemp)
|
||||||
|
|
||||||
|
# Change path from old USER to new USER_TO
|
||||||
|
sed "s|/home/$owner/public_html|/home/$USER_TO/public_html|g" "$filepath" > "$tmp_file"
|
||||||
|
|
||||||
|
# Check if replacement was successful and update file
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
mv "$tmp_file" "$filepath"
|
||||||
|
echo "$filename updated successfully."
|
||||||
|
else
|
||||||
|
echo "Failed to update $filename file."
|
||||||
|
rm "$tmp_file" # Deletes temporary file
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
filepath="/home/USER_TO/web/$domain/public_html/wordfence-waf.php"
|
||||||
|
filename=$(basename $filepath)
|
||||||
|
|
||||||
|
# Check if file exists
|
||||||
|
if [ -f "$filepath" ]; then
|
||||||
|
echo "Updating $filename with new user path..."
|
||||||
|
|
||||||
|
# Temporary file for modification
|
||||||
|
tmp_file=$(mktemp)
|
||||||
|
|
||||||
|
# Change path from old USER to new USER_TO
|
||||||
|
sed "s|/home/$owner/public_html|/home/$USER_TO/public_html|g" "$filepath" > "$tmp_file"
|
||||||
|
|
||||||
|
# Check if replacement was successful and update file
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
mv "$tmp_file" "$filepath"
|
||||||
|
echo "$filename updated successfully."
|
||||||
|
else
|
||||||
|
echo "Failed to update $filename file."
|
||||||
|
rm "$tmp_file" # Deletes temporary file
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
|
@ -19,6 +19,8 @@ fi
|
||||||
FROMFOLDER=$1
|
FROMFOLDER=$1
|
||||||
TOFOLDER=$2
|
TOFOLDER=$2
|
||||||
|
|
||||||
|
echo "Executing: v-move-folder-and-make-symlink $1 $2"
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
@ -26,6 +28,16 @@ source $VESTA/func/main.sh
|
||||||
# Verifications #
|
# Verifications #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
if [ -z "$FROMFOLDER" ]; then
|
||||||
|
echo "First parameter is empty, aborting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -z "$TOFOLDER" ]; then
|
||||||
|
echo "Second parameter is empty, aborting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# Trimming the ending slash, just in case
|
# Trimming the ending slash, just in case
|
||||||
FROMFOLDER=$(echo "$FROMFOLDER" | sed 's:/*$::')
|
FROMFOLDER=$(echo "$FROMFOLDER" | sed 's:/*$::')
|
||||||
TOFOLDER=$(echo "$TOFOLDER" | sed 's:/*$::')
|
TOFOLDER=$(echo "$TOFOLDER" | sed 's:/*$::')
|
||||||
|
@ -66,19 +78,21 @@ fi
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
rsync -a "$FROMFOLDER/" "$TOFOLDER/"
|
|
||||||
# with slashes on the end of the path of both folders
|
|
||||||
if [ "$?" -ne 0 ]; then
|
|
||||||
echo "Error happened, aborting"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "$FROMFOLDER" = "/home/$USER" ] && [ -d "$FROMFOLDER/conf" ]; then
|
if [ "$FROMFOLDER" = "/home/$USER" ] && [ -d "$FROMFOLDER/conf" ]; then
|
||||||
# if we are moving myVesta home folder, we must remove immutable attribute from conf/ files
|
# if we are moving myVesta home folder, we must remove immutable attribute from conf/ files
|
||||||
chattr -R -i "$FROMFOLDER/conf/" > /dev/null 2>&1
|
chattr -R -i "$FROMFOLDER/conf/" > /dev/null 2>&1
|
||||||
# with slashes on the end of the path of the folder
|
# with slashes on the end of the path of the folder
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# rsync -a "$FROMFOLDER/" "$TOFOLDER/"
|
||||||
|
# with slashes on the end of the path of both folders
|
||||||
|
|
||||||
|
mv "$FROMFOLDER" "$TOFOLDER"
|
||||||
|
if [ "$?" -ne 0 ]; then
|
||||||
|
echo "Error happened, aborting"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
rm -rf "$FROMFOLDER"
|
rm -rf "$FROMFOLDER"
|
||||||
# without slash on the end of the path of the folder
|
# without slash on the end of the path of the folder
|
||||||
|
|
||||||
|
|
|
@ -2,11 +2,20 @@
|
||||||
# info: calling myVesta PHP functions
|
# info: calling myVesta PHP functions
|
||||||
# options: FUNCTION
|
# options: FUNCTION
|
||||||
#
|
#
|
||||||
# The function is calling myVesta PHP functions.
|
# The function is calling myVesta or standard PHP functions directly from bash
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Action #
|
# Action #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$1" == "--stdin" ] && [ -p /dev/stdin ]; then
|
||||||
|
STDIN=$(cat -)
|
||||||
|
if [ ! -z "$STDIN" ]; then
|
||||||
|
echo "$STDIN" | php /usr/local/vesta/func/bash-to-php-interpreter.php "$@"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
php /usr/local/vesta/func/bash-to-php-interpreter.php "$@"
|
php /usr/local/vesta/func/bash-to-php-interpreter.php "$@"
|
||||||
exit $?
|
exit $?
|
||||||
|
|
|
@ -64,7 +64,9 @@ fi
|
||||||
|
|
||||||
# Resart web system if reload didn't work
|
# Resart web system if reload didn't work
|
||||||
if [ "$rc" -ne 0 ]; then
|
if [ "$rc" -ne 0 ]; then
|
||||||
service $WEB_SYSTEM restart >/dev/null 2>&1
|
# service $WEB_SYSTEM restart >/dev/null 2>&1
|
||||||
|
systemctl reset-failed $WEB_SYSTEM
|
||||||
|
systemctl restart $WEB_SYSTEM >/dev/null 2>&1
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
send_email_report
|
send_email_report
|
||||||
check_result $E_RESTART "$WEB_SYSTEM restart failed"
|
check_result $E_RESTART "$WEB_SYSTEM restart failed"
|
||||||
|
|
|
@ -417,6 +417,7 @@ if [ "$web" != 'no' ] && [ ! -z "$WEB_SYSTEM" ]; then
|
||||||
# Restoring web domain data
|
# Restoring web domain data
|
||||||
chown $user $tmpdir
|
chown $user $tmpdir
|
||||||
chmod u+w $HOMEDIR/$user/web/$domain
|
chmod u+w $HOMEDIR/$user/web/$domain
|
||||||
|
chmod 0755 $tmpdir/web/$domain
|
||||||
sudo -u $user tar -xzpf $tmpdir/web/$domain/domain_data.tar.gz \
|
sudo -u $user tar -xzpf $tmpdir/web/$domain/domain_data.tar.gz \
|
||||||
-C $HOMEDIR/$user/web/$domain/ --exclude=./logs/* \
|
-C $HOMEDIR/$user/web/$domain/ --exclude=./logs/* \
|
||||||
2> $HOMEDIR/$user/web/$domain/restore_errors.log
|
2> $HOMEDIR/$user/web/$domain/restore_errors.log
|
||||||
|
@ -618,6 +619,7 @@ if [ "$mail" != 'no' ] && [ ! -z "$MAIL_SYSTEM" ]; then
|
||||||
if [ -e "$tmpdir/mail/$domain/accounts.tar.gz" ]; then
|
if [ -e "$tmpdir/mail/$domain/accounts.tar.gz" ]; then
|
||||||
chown $user $tmpdir
|
chown $user $tmpdir
|
||||||
chmod u+w $HOMEDIR/$user/mail/$domain_idn
|
chmod u+w $HOMEDIR/$user/mail/$domain_idn
|
||||||
|
chmod 0755 $tmpdir/mail/$domain
|
||||||
sudo -u $user tar -xzpf $tmpdir/mail/$domain/accounts.tar.gz \
|
sudo -u $user tar -xzpf $tmpdir/mail/$domain/accounts.tar.gz \
|
||||||
-C $HOMEDIR/$user/mail/$domain_idn/
|
-C $HOMEDIR/$user/mail/$domain_idn/
|
||||||
if [ "$?" -ne 0 ]; then
|
if [ "$?" -ne 0 ]; then
|
||||||
|
|
102
bin/v-run-wp-cli
Normal file
102
bin/v-run-wp-cli
Normal file
|
@ -0,0 +1,102 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Run WP CLI command for a specific domain
|
||||||
|
# options: DOMAIN WP_CLI_COMMAND
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
SILENT_MODE=1
|
||||||
|
|
||||||
|
# Argument definition
|
||||||
|
domain=$1
|
||||||
|
wp_command=${@:2}
|
||||||
|
|
||||||
|
user=$(/usr/local/vesta/bin/v-search-domain-owner $domain)
|
||||||
|
USER=$user
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source /usr/local/vesta/func/main.sh
|
||||||
|
source /usr/local/vesta/func/domain.sh
|
||||||
|
|
||||||
|
if [ -z "$user" ]; then
|
||||||
|
check_result $E_NOTEXIST "domain $domain doesn't exist"
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Verifications #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
VERBOSE_MODE=1
|
||||||
|
|
||||||
|
check_args '2' "$#" 'DOMAIN WP_CLI_COMMAND'
|
||||||
|
is_format_valid 'domain'
|
||||||
|
is_object_valid 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'user' 'USER' "$user"
|
||||||
|
is_object_unsuspended 'web' 'DOMAIN' "$domain"
|
||||||
|
|
||||||
|
if [ ! -d "/home/$user" ]; then
|
||||||
|
# echo "User doesn't exist";
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "/home/$user/web/$domain/public_html/wp-config.php" ]; then
|
||||||
|
echo 'Please install WordPress first.'
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! command -v wp &> /dev/null; then
|
||||||
|
echo "WP CLI is not installed. Installing..."
|
||||||
|
wget -nv https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar -O /usr/local/bin/wp
|
||||||
|
chmod +x /usr/local/bin/wp
|
||||||
|
echo "WP CLI installed successfully."
|
||||||
|
fi
|
||||||
|
|
||||||
|
wpcli="/usr/local/bin/wp"
|
||||||
|
|
||||||
|
if [ -f "/usr/local/bin/wp-cli/php/boot-fs.php" ]; then
|
||||||
|
wpcli="/usr/local/bin/wp-cli/php/boot-fs.php"
|
||||||
|
COLUMNS=$(/usr/bin/env stty size 2>/dev/null | awk '{print $2}')
|
||||||
|
echo $COLUMNS > /usr/local/bin/wp-cli/COLUMNS
|
||||||
|
fi
|
||||||
|
|
||||||
|
mkdir -p /home/$user/.wp-cli
|
||||||
|
chown $user:$user /home/$user/.wp-cli
|
||||||
|
|
||||||
|
if [ -z "$PHP" ]; then
|
||||||
|
phpver=$(/usr/local/vesta/bin/v-get-php-version-of-domain "$domain")
|
||||||
|
else
|
||||||
|
phpver=$PHP
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
cd /home/$USER/web/$domain/public_html
|
||||||
|
sudo -u $USER /usr/bin/php$phpver -d disable_functions=pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,exec,system,passthru,shell_exec,proc_open,popen -d open_basedir=/home/$user/web/$domain:/home/$user/.wp-cli:/home/$user/tmp:/usr/local/bin $wpcli --path=/home/$user/web/$domain/public_html/ $wp_command 2>/home/$user/web/$domain/wp-cli-error.log
|
||||||
|
|
||||||
|
return_code=$?
|
||||||
|
|
||||||
|
if [ -f "/usr/local/bin/wp-cli/COLUMNS" ]; then
|
||||||
|
rm /usr/local/bin/wp-cli/COLUMNS
|
||||||
|
fi
|
||||||
|
|
||||||
|
# echo "WP CLI: Done."
|
||||||
|
# echo "To see Warning/Error log: "
|
||||||
|
# echo "cat /home/$user/web/$domain/wp-cli-error.log"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit $return_code;
|
27
bin/v-sed
Normal file
27
bin/v-sed
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: calling myvesta_sed PHP function
|
||||||
|
# options: PARAMETERS
|
||||||
|
#
|
||||||
|
# The function is calling myVesta PHP replacement for GNU 'sed' command (but without regular expression)
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$1" == "--stdin" ] && [ -p /dev/stdin ]; then
|
||||||
|
STDIN=$(cat -)
|
||||||
|
if [ ! -z "$STDIN" ]; then
|
||||||
|
shift;
|
||||||
|
echo "$STDIN" | php /usr/local/vesta/func/bash-to-php-interpreter.php '--stdin' 'myvesta_sed' "$@"
|
||||||
|
exit $?
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "$1" == "--stdin" ]; then
|
||||||
|
shift;
|
||||||
|
php /usr/local/vesta/func/bash-to-php-interpreter.php '--stdin' 'myvesta_sed' "$@"
|
||||||
|
else
|
||||||
|
php /usr/local/vesta/func/bash-to-php-interpreter.php 'myvesta_sed' "$@"
|
||||||
|
fi
|
||||||
|
exit $?
|
|
@ -17,6 +17,10 @@ domain=$2
|
||||||
domain_idn=$2
|
domain_idn=$2
|
||||||
restart=$3
|
restart=$3
|
||||||
|
|
||||||
|
if [ -z "$restart" ]; then
|
||||||
|
restart='yes'
|
||||||
|
fi
|
||||||
|
|
||||||
# Includes
|
# Includes
|
||||||
source $VESTA/func/main.sh
|
source $VESTA/func/main.sh
|
||||||
source $VESTA/func/domain.sh
|
source $VESTA/func/domain.sh
|
||||||
|
@ -80,12 +84,14 @@ fi
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
|
update_object_value 'web' 'DOMAIN' "$domain" '$SUSPENDED' 'yes'
|
||||||
increase_user_value "$user" '$SUSPENDED_WEB'
|
increase_user_value "$user" '$SUSPENDED_WEB'
|
||||||
|
|
||||||
# Restarting web server
|
if [ "$restart" = "yes" ]; then
|
||||||
$BIN/v-restart-web $restart
|
# Restarting web server
|
||||||
check_result $? "Web restart failed" >/dev/null
|
$BIN/v-restart-web $restart
|
||||||
|
check_result $? "Web restart failed" >/dev/null
|
||||||
$BIN/v-restart-proxy $restart
|
|
||||||
check_result $? "Proxy restart failed" >/dev/null
|
$BIN/v-restart-proxy $restart
|
||||||
|
check_result $? "Proxy restart failed" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
# Logging
|
# Logging
|
||||||
log_event "$OK" "$ARGUMENTS"
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
|
@ -58,6 +58,8 @@ chown -R $user:$user public_html/
|
||||||
|
|
||||||
rm public_html/wp-content/uploads/.htaccess
|
rm public_html/wp-content/uploads/.htaccess
|
||||||
|
|
||||||
|
/usr/local/vesta/bin/v-fix-website-permissions $domain
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
48
bin/v-update-document-errors-files
Normal file
48
bin/v-update-document-errors-files
Normal file
|
@ -0,0 +1,48 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: fix website permissions for all websites
|
||||||
|
# options:
|
||||||
|
#
|
||||||
|
# The command is used for fixing website permissions for all websites on the server.
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Importing system variables
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Includes
|
||||||
|
source $VESTA/func/main.sh
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
|
||||||
|
if [ ! -f "/usr/local/vesta/data/users/$user/user.conf" ]; then
|
||||||
|
continue;
|
||||||
|
fi
|
||||||
|
|
||||||
|
for domain in $(/usr/local/vesta/bin/v-list-web-domains $user plain |cut -f 1); do
|
||||||
|
cp /usr/local/vesta/data/templates/web/skel/document_errors/403.html /home/$user/web/$domain/document_errors/403.html
|
||||||
|
cp /usr/local/vesta/data/templates/web/skel/document_errors/404.html /home/$user/web/$domain/document_errors/404.html
|
||||||
|
cp /usr/local/vesta/data/templates/web/skel/document_errors/50x.html /home/$user/web/$domain/document_errors/50x.html
|
||||||
|
sed -i "s/%domain%/$domain/g" /home/$user/web/$domain/document_errors/403.html
|
||||||
|
sed -i "s/%domain%/$domain/g" /home/$user/web/$domain/document_errors/404.html
|
||||||
|
sed -i "s/%domain%/$domain/g" /home/$user/web/$domain/document_errors/50x.html
|
||||||
|
chown $user:$user /home/$user/web/$domain/document_errors/*
|
||||||
|
chmod 644 /home/$user/web/$domain/document_errors/*
|
||||||
|
done
|
||||||
|
|
||||||
|
done
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Vesta #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
# Logging
|
||||||
|
log_event "$OK" "$ARGUMENTS"
|
||||||
|
|
||||||
|
exit
|
|
@ -67,7 +67,7 @@ echo "$iptables -P INPUT ACCEPT" >> $tmp
|
||||||
echo "$iptables -F INPUT" >> $tmp
|
echo "$iptables -F INPUT" >> $tmp
|
||||||
|
|
||||||
# Enabling stateful support
|
# Enabling stateful support
|
||||||
if [ "$conntrack" != 'no' ] || grep --quiet container=lxc /proc/1/environ; then
|
if [ "$FIREWALL_STATEFUL" == "yes" ] || [ "$conntrack" != 'no' ] || grep --quiet container=lxc /proc/1/environ; then
|
||||||
str="$iptables -A INPUT -m state"
|
str="$iptables -A INPUT -m state"
|
||||||
str="$str --state ESTABLISHED,RELATED -j ACCEPT"
|
str="$str --state ESTABLISHED,RELATED -j ACCEPT"
|
||||||
echo "$str" >> $tmp
|
echo "$str" >> $tmp
|
||||||
|
@ -164,12 +164,12 @@ if [ ! -z "$FIREWALL_EXTENSION" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Saving rules to the master iptables file
|
# Saving rules to the master iptables file
|
||||||
if [ -d "/etc/sysconfig" ]; then
|
# if [ -d "/etc/sysconfig" ]; then
|
||||||
/sbin/iptables-save > /etc/sysconfig/iptables
|
# /sbin/iptables-save > /etc/sysconfig/iptables
|
||||||
if [ -z "$(ls /etc/rc3.d/S*iptables 2>/dev/null)" ]; then
|
# if [ -z "$(ls /etc/rc3.d/S*iptables 2>/dev/null)" ]; then
|
||||||
/sbin/chkconfig iptables on
|
# /sbin/chkconfig iptables on
|
||||||
fi
|
# fi
|
||||||
else
|
# else
|
||||||
/sbin/iptables-save > /etc/iptables.rules
|
/sbin/iptables-save > /etc/iptables.rules
|
||||||
preup="/etc/network/if-pre-up.d/iptables"
|
preup="/etc/network/if-pre-up.d/iptables"
|
||||||
if [ ! -e "$preup" ]; then
|
if [ ! -e "$preup" ]; then
|
||||||
|
@ -178,7 +178,7 @@ else
|
||||||
echo "exit 0" >> $preup
|
echo "exit 0" >> $preup
|
||||||
chmod +x $preup
|
chmod +x $preup
|
||||||
fi
|
fi
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
# Worarkound for OpenVZ
|
# Worarkound for OpenVZ
|
||||||
if [ -e "/proc/vz/veinfo" ]; then
|
if [ -e "/proc/vz/veinfo" ]; then
|
||||||
|
|
|
@ -49,7 +49,8 @@ dom_diks=0
|
||||||
for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do
|
for account in $(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT'); do
|
||||||
home_dir=$HOMEDIR/$user/mail/$domain/$account
|
home_dir=$HOMEDIR/$user/mail/$domain/$account
|
||||||
if [ -e "$home_dir" ]; then
|
if [ -e "$home_dir" ]; then
|
||||||
udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 )
|
cd $home_dir
|
||||||
|
udisk=$(nice -n 19 du -shm ./ | cut -f 1 )
|
||||||
else
|
else
|
||||||
udisk=0
|
udisk=0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -35,13 +35,14 @@ fi
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Starting loop
|
# Starting loop
|
||||||
for domain in $(search_objects 'mail' 'SUSPENDED' "no" 'DOMAIN'); do
|
for domain in $(list_objects 'mail' 'DOMAIN'); do
|
||||||
dom_diks=0
|
dom_diks=0
|
||||||
accounts=$(search_objects "mail/$domain" 'SUSPENDED' "no" 'ACCOUNT')
|
accounts=$(list_objects "mail/$domain" 'ACCOUNT')
|
||||||
for account in $accounts; do
|
for account in $accounts; do
|
||||||
home_dir=$HOMEDIR/$user/mail/$domain/$account
|
home_dir=$HOMEDIR/$user/mail/$domain/$account
|
||||||
if [ -e "$home_dir" ]; then
|
if [ -e "$home_dir" ]; then
|
||||||
udisk=$(nice -n 19 du -shm $home_dir | cut -f 1 )
|
cd $home_dir
|
||||||
|
udisk=$(nice -n 19 du -shm ./ | cut -f 1 )
|
||||||
else
|
else
|
||||||
udisk=0
|
udisk=0
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -74,7 +74,7 @@ rrdtool graph $RRD/la/$period-la.png \
|
||||||
-c "SHADEA#ffffff" \
|
-c "SHADEA#ffffff" \
|
||||||
-c "SHADEB#ffffff" \
|
-c "SHADEB#ffffff" \
|
||||||
-c "FONT#555555" \
|
-c "FONT#555555" \
|
||||||
-c "CANVAS#302c2d" \
|
-c "CANVAS#F2F2F2" \
|
||||||
-c "GRID#666666" \
|
-c "GRID#666666" \
|
||||||
-c "MGRID#AAAAAA" \
|
-c "MGRID#AAAAAA" \
|
||||||
-c "FRAME#777777" \
|
-c "FRAME#777777" \
|
||||||
|
@ -82,7 +82,7 @@ rrdtool graph $RRD/la/$period-la.png \
|
||||||
DEF:la=$RRD/la/la.rrd:LA:AVERAGE \
|
DEF:la=$RRD/la/la.rrd:LA:AVERAGE \
|
||||||
DEF:pr=$RRD/la/la.rrd:PR:AVERAGE \
|
DEF:pr=$RRD/la/la.rrd:PR:AVERAGE \
|
||||||
COMMENT:'\r' \
|
COMMENT:'\r' \
|
||||||
AREA:la#C8EA2E:"LA * 100"\
|
AREA:la#00CD2E:"LA * 100"\
|
||||||
GPRINT:la:'LAST: Current\:''%8.0lf' \
|
GPRINT:la:'LAST: Current\:''%8.0lf' \
|
||||||
GPRINT:la:'MIN: Min\:''%8.0lf' \
|
GPRINT:la:'MIN: Min\:''%8.0lf' \
|
||||||
GPRINT:la:'MAX: Max\:''%8.0lf\j' \
|
GPRINT:la:'MAX: Max\:''%8.0lf\j' \
|
||||||
|
|
|
@ -50,6 +50,14 @@ if [ -e "$home_dir" ]; then
|
||||||
disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 )
|
disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Defining hdd home directory
|
||||||
|
home_dir="/hdd$HOMEDIR/$user/web/$domain/"
|
||||||
|
|
||||||
|
# Checking home directory exist
|
||||||
|
if [ -e "$home_dir" ] && [[ ! -L "$home_dir" ]]; then
|
||||||
|
disk_usage2=$(nice -n 19 du -shm $home_dir | cut -f 1 )
|
||||||
|
disk_usage=$(( disk_usage + disk_usage2 ))
|
||||||
|
fi
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Vesta #
|
# Vesta #
|
||||||
|
|
|
@ -32,11 +32,16 @@ is_object_valid 'user' 'USER' "$user"
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
# Domain loop
|
# Domain loop
|
||||||
for domain in $(search_objects 'web' 'SUSPENDED' "no" 'DOMAIN'); do
|
for domain in $(list_objects 'web' 'DOMAIN'); do
|
||||||
home_dir="$HOMEDIR/$user/web/$domain/"
|
home_dir="$HOMEDIR/$user/web/$domain/"
|
||||||
if [ -e "$home_dir" ]; then
|
if [ -e "$home_dir" ]; then
|
||||||
disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 )
|
disk_usage=$(nice -n 19 du -shm $home_dir | cut -f 1 )
|
||||||
fi
|
fi
|
||||||
|
home_dir="/hdd$HOMEDIR/$user/web/$domain/"
|
||||||
|
if [ -e "$home_dir" ] && [[ ! -L "$home_dir" ]]; then
|
||||||
|
disk_usage2=$(nice -n 19 du -shm $home_dir | cut -f 1 )
|
||||||
|
disk_usage=$(( disk_usage + disk_usage2 ))
|
||||||
|
fi
|
||||||
update_object_value 'web' 'DOMAIN' "$domain" '$U_DISK' "$disk_usage"
|
update_object_value 'web' 'DOMAIN' "$domain" '$U_DISK' "$disk_usage"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
119
bin/v-whitelist-email-account
Normal file
119
bin/v-whitelist-email-account
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Add a specific email address to SpamAssassin whitelist
|
||||||
|
# usage: v-whitelist-email-account EMAIL
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Determine Debian version and set SpamAssassin service name
|
||||||
|
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
|
if [ "$release" -lt 12 ]; then
|
||||||
|
SPAMD_SERVICE="spamassassin.service"
|
||||||
|
else
|
||||||
|
SPAMD_SERVICE="spamd.service"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SPAMASSASSIN_FILE="/etc/spamassassin/local.cf"
|
||||||
|
|
||||||
|
# Flags to track changes
|
||||||
|
SPAMASSASSIN_CHANGED=false
|
||||||
|
|
||||||
|
# Function to check if an entry already exists in a file
|
||||||
|
check_entry_exists() {
|
||||||
|
local entry=$1
|
||||||
|
local file=$2
|
||||||
|
grep -qF "$entry" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to check if a domain/email is already blacklisted
|
||||||
|
check_blacklisted() {
|
||||||
|
local pattern=$1
|
||||||
|
local file=$2
|
||||||
|
grep -qE "blacklist_from.*${pattern}" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add an entry to a file
|
||||||
|
add_entry_to_file() {
|
||||||
|
local entry=$1
|
||||||
|
local file=$2
|
||||||
|
echo "$entry" >> "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display usage if no arguments are provided
|
||||||
|
if [ $# -lt 1 ]; then
|
||||||
|
echo "Usage: v-whitelist-email-account EMAIL"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
EMAIL=$1
|
||||||
|
|
||||||
|
# Validate email format
|
||||||
|
if [[ ! "$EMAIL" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]; then
|
||||||
|
echo "Invalid email address format."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Extract the domain from the email address
|
||||||
|
DOMAIN=$(echo "$EMAIL" | awk -F '@' '{print $2}')
|
||||||
|
|
||||||
|
# Prepare entries for SpamAssassin
|
||||||
|
WHITELIST_ENTRY="whitelist_from $EMAIL"
|
||||||
|
BLACKLIST_ENTRY_MAIN="*@${DOMAIN}"
|
||||||
|
BLACKLIST_ENTRY_SUB="*.$DOMAIN"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# SpamAssassin Whitelist #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
echo "Updating $SPAMASSASSIN_FILE..."
|
||||||
|
|
||||||
|
# Check if the email address or its domain is already blacklisted
|
||||||
|
if check_blacklisted "$EMAIL" "$SPAMASSASSIN_FILE"; then
|
||||||
|
echo "Cannot whitelist $EMAIL. It is already blacklisted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if check_blacklisted "$BLACKLIST_ENTRY_MAIN" "$SPAMASSASSIN_FILE"; then
|
||||||
|
echo "Cannot whitelist $EMAIL. The domain $DOMAIN is already blacklisted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if check_blacklisted "$BLACKLIST_ENTRY_SUB" "$SPAMASSASSIN_FILE"; then
|
||||||
|
echo "Cannot whitelist $EMAIL. The subdomain of $DOMAIN is already blacklisted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add the email to whitelist if not already present
|
||||||
|
if ! check_entry_exists "$WHITELIST_ENTRY" "$SPAMASSASSIN_FILE"; then
|
||||||
|
add_entry_to_file "$WHITELIST_ENTRY" "$SPAMASSASSIN_FILE"
|
||||||
|
echo "Added $WHITELIST_ENTRY to $SPAMASSASSIN_FILE."
|
||||||
|
SPAMASSASSIN_CHANGED=true
|
||||||
|
else
|
||||||
|
echo "$WHITELIST_ENTRY already exists in $SPAMASSASSIN_FILE."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restart SpamAssassin only if changes were made
|
||||||
|
if [ "$SPAMASSASSIN_CHANGED" == "true" ]; then
|
||||||
|
systemctl restart "$SPAMD_SERVICE"
|
||||||
|
echo "SpamAssassin service ($SPAMD_SERVICE) restarted."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Done #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit 0
|
119
bin/v-whitelist-email-domain
Normal file
119
bin/v-whitelist-email-domain
Normal file
|
@ -0,0 +1,119 @@
|
||||||
|
#!/bin/bash
|
||||||
|
# info: Add a domain to SpamAssassin whitelist
|
||||||
|
# usage: v-whitelist-email-domain DOMAIN SUBDOMAIN(YES/NO)
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Variable&Function #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
whoami=$(whoami)
|
||||||
|
if [ "$whoami" != "root" ]; then
|
||||||
|
echo "You must be root to execute this script"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Importing system environment
|
||||||
|
source /etc/profile
|
||||||
|
|
||||||
|
# Determine Debian version and set SpamAssassin service name
|
||||||
|
release=$(cat /etc/debian_version | tr "." "\n" | head -n1)
|
||||||
|
if [ "$release" -lt 12 ]; then
|
||||||
|
SPAMD_SERVICE="spamassassin.service"
|
||||||
|
else
|
||||||
|
SPAMD_SERVICE="spamd.service"
|
||||||
|
fi
|
||||||
|
|
||||||
|
SPAMASSASSIN_FILE="/etc/spamassassin/local.cf"
|
||||||
|
|
||||||
|
# Flags to track changes
|
||||||
|
SPAMASSASSIN_CHANGED=false
|
||||||
|
|
||||||
|
# Function to check if a SpamAssassin whitelist entry already exists
|
||||||
|
check_whitelist_exists() {
|
||||||
|
local entry=$1
|
||||||
|
local file=$2
|
||||||
|
grep -qF "whitelist_from $entry" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to check if a domain/email is already blacklisted
|
||||||
|
check_blacklist_exists() {
|
||||||
|
local domain=$1
|
||||||
|
local file=$2
|
||||||
|
grep -qE "blacklist_from.*${domain}$" "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Function to add whitelist entry to file
|
||||||
|
add_whitelist_to_file() {
|
||||||
|
local entry=$1
|
||||||
|
local file=$2
|
||||||
|
echo "whitelist_from $entry" >> "$file"
|
||||||
|
}
|
||||||
|
|
||||||
|
# Display usage if no arguments are provided
|
||||||
|
if [ $# -lt 2 ]; then
|
||||||
|
echo "Usage: v-whitelist-email-domain DOMAIN SUBDOMAIN(YES/NO)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Action #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
DOMAIN=$1
|
||||||
|
SUBDOMAIN=${2^^} # Convert to uppercase for consistency (YES/NO)
|
||||||
|
|
||||||
|
# Validate SUBDOMAIN parameter
|
||||||
|
if [[ "$SUBDOMAIN" != "YES" && "$SUBDOMAIN" != "NO" ]]; then
|
||||||
|
echo "Invalid parameter for SUBDOMAIN. Use YES or NO."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Prepare entries for SpamAssassin
|
||||||
|
WHITELIST_ENTRY_MAIN="*@${DOMAIN}"
|
||||||
|
WHITELIST_ENTRY_SUB="*.$DOMAIN"
|
||||||
|
BLACKLIST_ENTRY_MAIN="*@${DOMAIN}"
|
||||||
|
BLACKLIST_ENTRY_SUB="*.$DOMAIN"
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# SpamAssassin Whitelist #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
echo "Updating $SPAMASSASSIN_FILE..."
|
||||||
|
|
||||||
|
# Check if the domain is already blacklisted
|
||||||
|
if check_blacklist_exists "$DOMAIN" "$SPAMASSASSIN_FILE"; then
|
||||||
|
echo "Cannot whitelist $DOMAIN. It is already blacklisted."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add the main entry
|
||||||
|
if ! check_whitelist_exists "$WHITELIST_ENTRY_MAIN" "$SPAMASSASSIN_FILE"; then
|
||||||
|
add_whitelist_to_file "$WHITELIST_ENTRY_MAIN" "$SPAMASSASSIN_FILE"
|
||||||
|
echo "Added whitelist_from $WHITELIST_ENTRY_MAIN to $SPAMASSASSIN_FILE."
|
||||||
|
SPAMASSASSIN_CHANGED=true
|
||||||
|
else
|
||||||
|
echo "whitelist_from $WHITELIST_ENTRY_MAIN already exists in $SPAMASSASSIN_FILE."
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Add the subdomain entry if needed
|
||||||
|
if [ "$SUBDOMAIN" == "YES" ]; then
|
||||||
|
if ! check_whitelist_exists "$WHITELIST_ENTRY_SUB" "$SPAMASSASSIN_FILE"; then
|
||||||
|
add_whitelist_to_file "$WHITELIST_ENTRY_SUB" "$SPAMASSASSIN_FILE"
|
||||||
|
echo "Added whitelist_from $WHITELIST_ENTRY_SUB to $SPAMASSASSIN_FILE."
|
||||||
|
SPAMASSASSIN_CHANGED=true
|
||||||
|
else
|
||||||
|
echo "whitelist_from $WHITELIST_ENTRY_SUB already exists in $SPAMASSASSIN_FILE."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Restart SpamAssassin only if changes were made
|
||||||
|
if [ "$SPAMASSASSIN_CHANGED" == "true" ]; then
|
||||||
|
systemctl restart "$SPAMD_SERVICE"
|
||||||
|
echo "SpamAssassin service ($SPAMD_SERVICE) restarted."
|
||||||
|
fi
|
||||||
|
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
# Done #
|
||||||
|
#----------------------------------------------------------#
|
||||||
|
|
||||||
|
exit 0
|
|
@ -7,24 +7,73 @@ else $SHLVL=3;
|
||||||
|
|
||||||
if (!isset($argv)) exit(5);
|
if (!isset($argv)) exit(5);
|
||||||
|
|
||||||
|
$argv_start=1;
|
||||||
|
$STDIN_ENABLED=false;
|
||||||
|
if ($argv[1]=='--stdin') {
|
||||||
|
$STDIN_ENABLED=true;
|
||||||
|
$argv_start++;
|
||||||
|
}
|
||||||
|
|
||||||
|
$myvesta_stdin='';
|
||||||
|
if ($STDIN_ENABLED==true) {
|
||||||
|
stream_set_blocking(STDIN, false);
|
||||||
|
$myvesta_f = fopen( 'php://stdin', 'r' );
|
||||||
|
while( $myvesta_line = fgets( $myvesta_f ) ) {
|
||||||
|
$myvesta_stdin .= $myvesta_line;
|
||||||
|
}
|
||||||
|
fclose( $myvesta_f );
|
||||||
|
}
|
||||||
|
|
||||||
include ("/usr/local/vesta/func/main.php");
|
include ("/usr/local/vesta/func/main.php");
|
||||||
include ("/usr/local/vesta/func/string.php");
|
include ("/usr/local/vesta/func/string.php");
|
||||||
|
|
||||||
$counter=count($argv);
|
$counter=count($argv);
|
||||||
if ($counter<2) myvesta_throw_error(2, 'Function is missing');
|
if ($counter<2) myvesta_throw_error(2, 'Function is missing');
|
||||||
|
|
||||||
$func=$argv[1];
|
$func=$argv[$argv_start];
|
||||||
if (!function_exists($func)) {
|
if (!function_exists($func)) {
|
||||||
$func="myvesta_".$argv[1];
|
$func="myvesta_".$argv[$argv_start];
|
||||||
if (!function_exists($func)) myvesta_throw_error(2, 'Function does not exists');
|
if (!function_exists($func)) myvesta_throw_error(2, 'Function does not exists');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$insert_stdin_at_position=false;
|
||||||
|
if ($func=="myvesta_grep") $insert_stdin_at_position=1;
|
||||||
|
if ($func=="myvesta_sed") $insert_stdin_at_position=2;
|
||||||
|
|
||||||
$params=array();
|
$params=array();
|
||||||
|
|
||||||
for ($i=2; $i<$counter; $i++) {
|
$added=0;
|
||||||
|
$stdin_content='';
|
||||||
|
$myvesta_stdin_from_file='';
|
||||||
|
$myvesta_stdin_return_not_found=false;
|
||||||
|
if ($myvesta_stdin!='' && $insert_stdin_at_position===false) {$params[]=$myvesta_stdin; $added++;}
|
||||||
|
|
||||||
|
$argv_start++;
|
||||||
|
|
||||||
|
for ($i=$argv_start; $i<$counter; $i++) {
|
||||||
$argv[$i]=myvesta_fix_backslashes($argv[$i]);
|
$argv[$i]=myvesta_fix_backslashes($argv[$i]);
|
||||||
|
//if ($insert_stdin_at_position!==false && $myvesta_stdin=='') if ($insert_stdin_at_position==$added) {$stdin_content=$argv[$i]; $added++; continue;}
|
||||||
$params[]=$argv[$i];
|
$params[]=$argv[$i];
|
||||||
|
$added++;
|
||||||
}
|
}
|
||||||
|
//print_r($params); exit;
|
||||||
|
|
||||||
|
if ($insert_stdin_at_position!=false) {
|
||||||
|
if ($myvesta_stdin=='' && isset($params[$insert_stdin_at_position])) {
|
||||||
|
$file_or_stdin=$params[$insert_stdin_at_position];
|
||||||
|
if (!file_exists($file_or_stdin)) {
|
||||||
|
$myvesta_stdin_return_not_found=true;
|
||||||
|
$myvesta_stdin='';
|
||||||
|
} else {
|
||||||
|
$myvesta_stdin=file_get_contents($file_or_stdin);
|
||||||
|
$myvesta_stdin_from_file=$file_or_stdin;
|
||||||
|
}
|
||||||
|
$params[$insert_stdin_at_position]=$myvesta_stdin;
|
||||||
|
} else {
|
||||||
|
array_splice($params, $insert_stdin_at_position, 0, array($myvesta_stdin));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//print_r($params); exit;
|
||||||
|
|
||||||
$r=call_user_func_array($func, $params);
|
$r=call_user_func_array($func, $params);
|
||||||
if (is_bool($r)) {
|
if (is_bool($r)) {
|
||||||
|
|
14
func/db.sh
14
func/db.sh
|
@ -29,6 +29,9 @@ mysql_connect() {
|
||||||
mysql --defaults-file=$mycnf -e 'SELECT VERSION()' > $mysql_out 2>&1
|
mysql --defaults-file=$mycnf -e 'SELECT VERSION()' > $mysql_out 2>&1
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
if [ "$notify" != 'no' ]; then
|
if [ "$notify" != 'no' ]; then
|
||||||
|
subj="Error: Connection to $HOST failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo -e "Can't connect to MySQL $HOST\n$(cat $mysql_out)" |\
|
echo -e "Can't connect to MySQL $HOST\n$(cat $mysql_out)" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
@ -55,10 +58,13 @@ mysql_query() {
|
||||||
|
|
||||||
mysql_dump() {
|
mysql_dump() {
|
||||||
err="/tmp/e.mysql"
|
err="/tmp/e.mysql"
|
||||||
mysqldump --defaults-file=$mycnf --single-transaction --max_allowed_packet=100M -r $1 $2 2> $err
|
mysqldump --defaults-file=$mycnf --complete-insert --force --quick --single-transaction --max-allowed-packet=1024MB -r $1 $2 2> $err
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
if [ "$notify" != 'no' ]; then
|
if [ "$notify" != 'no' ]; then
|
||||||
|
subj="Error: dump $database failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo -e "Can't dump database $database\n$(cat $err)" |\
|
echo -e "Can't dump database $database\n$(cat $err)" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
@ -82,6 +88,9 @@ psql_connect() {
|
||||||
psql -h $HOST -U $USER -c "SELECT VERSION()" > /dev/null 2>/tmp/e.psql
|
psql -h $HOST -U $USER -c "SELECT VERSION()" > /dev/null 2>/tmp/e.psql
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
if [ "$notify" != 'no' ]; then
|
if [ "$notify" != 'no' ]; then
|
||||||
|
subj="Error: Connection to $HOST failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo -e "Can't connect to PostgreSQL $HOST\n$(cat /tmp/e.psql)" |\
|
echo -e "Can't connect to PostgreSQL $HOST\n$(cat /tmp/e.psql)" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
@ -103,6 +112,9 @@ psql_dump() {
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
if [ "$notify" != 'no' ]; then
|
if [ "$notify" != 'no' ]; then
|
||||||
|
subj="Error: dump $database failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo -e "Can't dump database $database\n$(cat /tmp/e.psql)" |\
|
echo -e "Can't dump database $database\n$(cat /tmp/e.psql)" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -1,6 +1,9 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$myvesta_exit_on_error=true;
|
$myvesta_exit_on_error=true;
|
||||||
|
$myvesta_quiet_mode=0;
|
||||||
|
if (isset($_SERVER['MYVESTA_QUIET'])) $myvesta_quiet_mode=intval($_SERVER['MYVESTA_QUIET']);
|
||||||
|
|
||||||
define('MYVESTA_ERROR_PERMISSION_DENIED', 1);
|
define('MYVESTA_ERROR_PERMISSION_DENIED', 1);
|
||||||
define('MYVESTA_ERROR_MISSING_ARGUMENTS', 2);
|
define('MYVESTA_ERROR_MISSING_ARGUMENTS', 2);
|
||||||
define('MYVESTA_ERROR_FILE_DOES_NOT_EXISTS', 3);
|
define('MYVESTA_ERROR_FILE_DOES_NOT_EXISTS', 3);
|
||||||
|
@ -8,18 +11,22 @@ define('MYVESTA_ERROR_STRING_NOT_FOUND', 4);
|
||||||
define('MYVESTA_ERROR_GENERAL', 5);
|
define('MYVESTA_ERROR_GENERAL', 5);
|
||||||
|
|
||||||
function myvesta_echo($str) {
|
function myvesta_echo($str) {
|
||||||
global $myvesta_echo_done, $myvesta_last_echo;
|
global $myvesta_echo_done, $myvesta_last_echo, $myvesta_quiet_mode;
|
||||||
|
if ($myvesta_quiet_mode==1) return;
|
||||||
$myvesta_echo_done=true;
|
$myvesta_echo_done=true;
|
||||||
$myvesta_last_echo=$str;
|
$myvesta_last_echo=$str;
|
||||||
echo $str;
|
echo $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
function myvesta_exit($code) {
|
function myvesta_exit($code, $echo='') {
|
||||||
global $SHLVL, $myvesta_echo_done, $myvesta_last_echo;
|
global $SHLVL, $myvesta_echo_done, $myvesta_last_echo, $myvesta_quiet_mode;
|
||||||
// myvesta_echo ("==================== ".$argv[0].": ".$code." ====================\n");
|
// myvesta_echo ("==================== ".$argv[0].": ".$code." ====================\n");
|
||||||
if ($SHLVL<3 && $myvesta_echo_done==true) {
|
if ($myvesta_quiet_mode!=1) {
|
||||||
$last_char=substr($myvesta_last_echo, -1, 1);
|
if ($echo!='') myvesta_echo($echo);
|
||||||
if ($last_char!="\n") echo "\n";
|
if ($SHLVL<3 && $myvesta_echo_done==true) {
|
||||||
|
$last_char=substr($myvesta_last_echo, -1, 1);
|
||||||
|
if ($last_char!="\n") echo "\n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
exit($code);
|
exit($code);
|
||||||
}
|
}
|
||||||
|
@ -28,8 +35,8 @@ $myvesta_current_user=exec('whoami', $myvesta_output, $myvesta_return_var);
|
||||||
if ($myvesta_current_user != 'root') {myvesta_echo ("ERROR: You must be root to execute this script"); myvesta_exit(1);}
|
if ($myvesta_current_user != 'root') {myvesta_echo ("ERROR: You must be root to execute this script"); myvesta_exit(1);}
|
||||||
|
|
||||||
function myvesta_throw_error($code, $message) {
|
function myvesta_throw_error($code, $message) {
|
||||||
global $myvesta_exit_on_error;
|
global $myvesta_exit_on_error, $myvesta_quiet_mode;
|
||||||
if ($message!=='') myvesta_echo ("ERROR: ".$message);
|
if ($message!=='' && $myvesta_quiet_mode!=1) myvesta_echo ("ERROR: ".$message);
|
||||||
if ($myvesta_exit_on_error) myvesta_exit($code);
|
if ($myvesta_exit_on_error) myvesta_exit($code);
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
|
@ -46,6 +53,7 @@ function myvesta_check_args ($requried_arguments, $arguments) {
|
||||||
$argument_counter=count($argv);
|
$argument_counter=count($argv);
|
||||||
$argument_counter--;
|
$argument_counter--;
|
||||||
$argv[0]=str_replace('/usr/local/vesta/bin/', '', $argv[0]);
|
$argv[0]=str_replace('/usr/local/vesta/bin/', '', $argv[0]);
|
||||||
|
$command=$argv[0];
|
||||||
// myvesta_echo ( "-------------------- ".$argv[0]." --------------------\n");
|
// myvesta_echo ( "-------------------- ".$argv[0]." --------------------\n");
|
||||||
if ($argument_counter<$requried_arguments) {
|
if ($argument_counter<$requried_arguments) {
|
||||||
$arguments=str_replace(" ", "' '", $arguments);
|
$arguments=str_replace(" ", "' '", $arguments);
|
||||||
|
|
93
func/main.sh
93
func/main.sh
|
@ -254,6 +254,9 @@ is_object_unsuspended() {
|
||||||
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf |grep "SUSPENDED='yes'")
|
spnd=$(grep "$2='$3'" $USER_DATA/$1.conf |grep "SUSPENDED='yes'")
|
||||||
fi
|
fi
|
||||||
if [ ! -z "$spnd" ]; then
|
if [ ! -z "$spnd" ]; then
|
||||||
|
if [ ! -z "$VERBOSE_MODE" ]; then
|
||||||
|
echo "Error: $(basename $1) $3 is suspended"
|
||||||
|
fi
|
||||||
check_result $E_SUSPENDED "$(basename $1) $3 is suspended"
|
check_result $E_SUSPENDED "$(basename $1) $3 is suspended"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -359,6 +362,17 @@ search_objects() {
|
||||||
IFS="$OLD_IFS"
|
IFS="$OLD_IFS"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# List objects
|
||||||
|
list_objects() {
|
||||||
|
OLD_IFS="$IFS"
|
||||||
|
IFS=$'\n'
|
||||||
|
for line in $(cat $USER_DATA/$1.conf); do
|
||||||
|
eval $line
|
||||||
|
eval echo \$$2
|
||||||
|
done
|
||||||
|
IFS="$OLD_IFS"
|
||||||
|
}
|
||||||
|
|
||||||
# Get user value
|
# Get user value
|
||||||
get_user_value() {
|
get_user_value() {
|
||||||
grep "^${1//$/}=" $USER_DATA/user.conf |awk -F "'" '{print $2}'
|
grep "^${1//$/}=" $USER_DATA/user.conf |awk -F "'" '{print $2}'
|
||||||
|
@ -1143,3 +1157,82 @@ check_if_service_exists() {
|
||||||
echo "0"
|
echo "0"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Parsing config variables with key='value' and key="value" pairs and setting them as variables, without using Perl.
|
||||||
|
# Inspired by HestiaCP function and improved
|
||||||
|
parse_object_kv_list_non_eval() {
|
||||||
|
# Let's combine all the parameters into one string, replace the new lines with a space
|
||||||
|
local str="${*//$'\n'/ }"
|
||||||
|
str=${str//\\\'/---QUOTE---}
|
||||||
|
str=${str//\\\"/---DQUOTE---}
|
||||||
|
local backup_str=$str
|
||||||
|
|
||||||
|
local key val match i length length_val prefix position cut
|
||||||
|
i=0
|
||||||
|
# Searching for key='value' blocks
|
||||||
|
# Loop until we find the next key='value'
|
||||||
|
while [[ $str =~ ([A-Za-z][[:alnum:]_]*)=\'([^\']*)\' ]]; do
|
||||||
|
key="${BASH_REMATCH[1]}"
|
||||||
|
val="${BASH_REMATCH[2]}"
|
||||||
|
match="${BASH_REMATCH[0]}"
|
||||||
|
length=${#match}
|
||||||
|
length_val=${#match}
|
||||||
|
|
||||||
|
# Key validation: alphanumeric, length 2–66 (key must start and end with a letter/number)
|
||||||
|
if ! [[ "$key" =~ ^[[:alnum:]][_[:alnum:]]{0,64}[[:alnum:]]$ ]]; then
|
||||||
|
check_result "$E_INVALID" "Invalid key format [$key]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Declaring a global variable
|
||||||
|
val=${val/---QUOTE---/\\\'}
|
||||||
|
val=${val/---DQUOTE---/\\\"}
|
||||||
|
declare -g "$key"="$val"
|
||||||
|
|
||||||
|
# Let's remove the processed part from str to continue
|
||||||
|
prefix=${str%%"$key="*}
|
||||||
|
position=${#prefix}
|
||||||
|
cut=$((position + 1 + length_val))
|
||||||
|
str=${str:cut}
|
||||||
|
((i++))
|
||||||
|
if [ $i -eq 100 ]; then
|
||||||
|
check_result "$E_INVALID" "Potentially conf-parsing infinite loop detected"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
# Terminate function if we don't expect strings with double apostrophes
|
||||||
|
if [ -z "$PARSE_DOUBLE_QUOTES_VAR" ]; then
|
||||||
|
return;
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Searching for key="value" blocks
|
||||||
|
str=$backup_str
|
||||||
|
i=0
|
||||||
|
# Loop until we find the next key="value"
|
||||||
|
while [[ $str =~ ([A-Za-z][[:alnum:]_]*)=\"([^\"]*)\" ]]; do
|
||||||
|
key="${BASH_REMATCH[1]}"
|
||||||
|
val="${BASH_REMATCH[2]}"
|
||||||
|
match="${BASH_REMATCH[0]}"
|
||||||
|
length=${#match}
|
||||||
|
length_val=${#match}
|
||||||
|
|
||||||
|
# Key validation: alphanumeric, length 2–66 (key must start and end with a letter/number)
|
||||||
|
if ! [[ "$key" =~ ^[[:alnum:]][_[:alnum:]]{0,64}[[:alnum:]]$ ]]; then
|
||||||
|
check_result "$E_INVALID" "Invalid key format [$key]"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Declaring a global variable
|
||||||
|
val=${val/---QUOTE---/\\\'}
|
||||||
|
val=${val/---DQUOTE---/\\\"}
|
||||||
|
declare -g "$key"="$val"
|
||||||
|
|
||||||
|
# Let's remove the processed part from str to continue
|
||||||
|
prefix=${str%%"$key="*}
|
||||||
|
position=${#prefix}
|
||||||
|
cut=$((position + 1 + length_val))
|
||||||
|
str=${str:cut}
|
||||||
|
((i++))
|
||||||
|
if [ $i -eq 100 ]; then
|
||||||
|
check_result "$E_INVALID" "Potentially conf-parsing infinite loop detected"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
}
|
||||||
|
|
|
@ -610,6 +610,9 @@ rebuild_pgsql_database() {
|
||||||
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
if [ -z $HOST ] || [ -z $USER ] || [ -z $PASSWORD ] || [ -z $TPL ]; then
|
||||||
echo "Error: postgresql config parsing failed"
|
echo "Error: postgresql config parsing failed"
|
||||||
if [ ! -z "$SENDMAIL" ]; then
|
if [ ! -z "$SENDMAIL" ]; then
|
||||||
|
subj="Error: postgresql config parsing failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo "Can't parse PostgreSQL config" | $SENDMAIL -s "$subj" $email
|
echo "Can't parse PostgreSQL config" | $SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
log_event "$E_PARSING" "$ARGUMENTS"
|
log_event "$E_PARSING" "$ARGUMENTS"
|
||||||
|
@ -621,6 +624,9 @@ rebuild_pgsql_database() {
|
||||||
if [ '0' -ne "$?" ]; then
|
if [ '0' -ne "$?" ]; then
|
||||||
echo "Error: Connection failed"
|
echo "Error: Connection failed"
|
||||||
if [ ! -z "$SENDMAIL" ]; then
|
if [ ! -z "$SENDMAIL" ]; then
|
||||||
|
subj="Error: Connection failed"
|
||||||
|
email=$($BIN/v-get-user-value admin CONTACT)
|
||||||
|
|
||||||
echo "Database connection to PostgreSQL host $HOST failed" |\
|
echo "Database connection to PostgreSQL host $HOST failed" |\
|
||||||
$SENDMAIL -s "$subj" $email
|
$SENDMAIL -s "$subj" $email
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -2,14 +2,18 @@
|
||||||
|
|
||||||
// --- file functions ---
|
// --- file functions ---
|
||||||
|
|
||||||
function myvesta_find_in_file($file, $find) {
|
function myvesta_find_in_file($file, $find, $quiet=false) {
|
||||||
if (!file_exists($file)) return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, "File '$file' not found");
|
if (!file_exists($file)) {
|
||||||
|
if ($quiet) return false;
|
||||||
|
return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, "File '$file' not found");
|
||||||
|
}
|
||||||
|
|
||||||
$buf=file_get_contents($file);
|
$buf=file_get_contents($file);
|
||||||
|
|
||||||
$pos=strpos($buf, $find);
|
$pos=strpos($buf, $find);
|
||||||
|
|
||||||
if ($pos===false) return myvesta_throw_error (MYVESTA_ERROR_STRING_NOT_FOUND, "");
|
if ($pos===false) return myvesta_throw_error (MYVESTA_ERROR_STRING_NOT_FOUND, "");
|
||||||
|
if ($quiet) return true;
|
||||||
return $pos;
|
return $pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,6 +72,60 @@ function myvesta_strip_in_file_between_including_borders($file, $left, $right) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- mixed functions ---
|
||||||
|
|
||||||
|
function myvesta_grep($find, $content, $count=0, $quiet=0) {
|
||||||
|
global $myvesta_stdin, $myvesta_stdin_return_not_found, $myvesta_quiet_mode;
|
||||||
|
if ($count==='-c') {$count=1; $quiet=0;}
|
||||||
|
if ($count==='-q') {$count=0; $quiet=1;}
|
||||||
|
if ($myvesta_quiet_mode==0) $myvesta_quiet_mode=$quiet;
|
||||||
|
//echo "find = " . $find."\n"; echo "file_or_stdin = " . $content."\n"; echo "count = " . $count."\n"; echo "quiet = " . $quiet."\n"; exit;
|
||||||
|
if ($myvesta_stdin_return_not_found==true) {
|
||||||
|
if ($count==1) return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, "0");
|
||||||
|
return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, "");
|
||||||
|
}
|
||||||
|
|
||||||
|
$arr=explode("\n", $content);
|
||||||
|
|
||||||
|
$buffer='';
|
||||||
|
$hits=0;
|
||||||
|
foreach ($arr as $line) {
|
||||||
|
if (strpos($line, $find)!==false) {
|
||||||
|
$hits++;
|
||||||
|
if ($quiet==false && $count==false) $buffer.=$line."\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($count==1) {
|
||||||
|
if ($hits==0) return myvesta_exit (MYVESTA_ERROR_STRING_NOT_FOUND, "0");
|
||||||
|
return $hits;
|
||||||
|
}
|
||||||
|
if ($quiet==1) {
|
||||||
|
if ($hits==0) return myvesta_exit (MYVESTA_ERROR_STRING_NOT_FOUND, "");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if ($hits==0) return myvesta_exit (MYVESTA_ERROR_STRING_NOT_FOUND, "");
|
||||||
|
return $buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
function myvesta_sed($find, $replace, $content) {
|
||||||
|
global $myvesta_stdin, $myvesta_stdin_return_not_found, $myvesta_stdin_from_file;
|
||||||
|
//echo "find = " . $find."\n"; echo "replace = " . $replace."\n"; echo "file_or_stdin = " . $content."\n"; echo "stdin_from_file = " . $myvesta_stdin_from_file."\n"; exit;
|
||||||
|
if ($myvesta_stdin_return_not_found==true) {
|
||||||
|
return myvesta_throw_error (MYVESTA_ERROR_FILE_DOES_NOT_EXISTS, "File not found");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (strpos($content, $find)===false) return myvesta_throw_error (MYVESTA_ERROR_STRING_NOT_FOUND, "String '$find' not found");
|
||||||
|
|
||||||
|
$content=str_replace($find, $replace, $content);
|
||||||
|
if ($myvesta_stdin_from_file!='') {
|
||||||
|
$r=file_put_contents($myvesta_stdin_from_file, $content);
|
||||||
|
if ($r===false) return false;
|
||||||
|
} else {
|
||||||
|
myvesta_echo ($content);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// --- string functions ---
|
// --- string functions ---
|
||||||
|
|
||||||
function myvesta_str_get_between (&$text, $left_substring, $right_substring, $start=0, $return_left_substring=0, $return_right_substring=0, $left_substring_necessary=1, $right_substring_necessary=1) {
|
function myvesta_str_get_between (&$text, $left_substring, $right_substring, $start=0, $return_left_substring=0, $return_right_substring=0, $left_substring_necessary=1, $right_substring_necessary=1) {
|
||||||
|
@ -136,6 +194,17 @@ function myvesta_str_replace_between_including_borders($text, $left, $right, $re
|
||||||
}
|
}
|
||||||
|
|
||||||
function myvesta_str_strip_between_including_borders($text, $left, $right) {
|
function myvesta_str_strip_between_including_borders($text, $left, $right) {
|
||||||
|
global $myvesta_stdin;
|
||||||
|
$args=func_get_args();
|
||||||
|
$args_i=-1;
|
||||||
|
if ($myvesta_stdin!='') {
|
||||||
|
$text=$myvesta_stdin;
|
||||||
|
} else {
|
||||||
|
$args_i++; $text=$args[$args_i];
|
||||||
|
}
|
||||||
|
$args_i++; $left=$args[$args_i];
|
||||||
|
$args_i++; $right=$args[$args_i];
|
||||||
|
|
||||||
$left_len=strlen($left);
|
$left_len=strlen($left);
|
||||||
$right_len=strlen($right);
|
$right_len=strlen($right);
|
||||||
while (true) {
|
while (true) {
|
||||||
|
@ -147,3 +216,23 @@ function myvesta_str_strip_between_including_borders($text, $left, $right) {
|
||||||
}
|
}
|
||||||
return $text;
|
return $text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function myvesta_str_find($text, $find, $quiet=false) {
|
||||||
|
$pos=strpos($text, $find);
|
||||||
|
if ($pos===false) return myvesta_throw_error (MYVESTA_ERROR_STRING_NOT_FOUND, "");
|
||||||
|
if ($quiet) return true;
|
||||||
|
return $pos;
|
||||||
|
}
|
||||||
|
|
||||||
|
function myvesta_str_uppercase($text) {
|
||||||
|
return strtoupper($text);
|
||||||
|
}
|
||||||
|
|
||||||
|
function myvesta_str_lowercase($text) {
|
||||||
|
return strtolower($text);
|
||||||
|
}
|
||||||
|
|
||||||
|
function myvesta_str_substring($text, $start, $length=null) {
|
||||||
|
if ($length===null) return substr($text, $start);
|
||||||
|
if ($length!==null) return substr($text, $start, $length);
|
||||||
|
}
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
bl.spamcop.net
|
bl.spamcop.net
|
||||||
zen.spamhaus.org
|
|
||||||
|
|
|
@ -91,16 +91,18 @@ acl_check_mail:
|
||||||
deny condition = ${if eq{$sender_helo_name}{}}
|
deny condition = ${if eq{$sender_helo_name}{}}
|
||||||
message = HELO required before MAIL
|
message = HELO required before MAIL
|
||||||
|
|
||||||
drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
|
drop !authenticated = *
|
||||||
|
message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
|
||||||
condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
|
condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
|
||||||
condition = ${if match{${lc:$sender_host_name}}{.telenor.rs}{false}{true}}
|
|
||||||
condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
|
condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
|
||||||
delay = 45s
|
delay = 45s
|
||||||
|
|
||||||
drop condition = ${if isip{$sender_helo_name}}
|
drop !authenticated = *
|
||||||
|
condition = ${if isip{$sender_helo_name}}
|
||||||
message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
|
message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
|
||||||
|
|
||||||
drop condition = ${if eq{[$interface_address]}{$sender_helo_name}}
|
drop !authenticated = *
|
||||||
|
condition = ${if eq{[$interface_address]}{$sender_helo_name}}
|
||||||
message = $interface_address is _my_ address
|
message = $interface_address is _my_ address
|
||||||
|
|
||||||
accept
|
accept
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<Directory %sdocroot%>
|
<Directory %sdocroot%>
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
SSLRequireSSL
|
SSLRequireSSL
|
||||||
Options +Includes -Indexes +ExecCGI
|
Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
|
||||||
</Directory>
|
</Directory>
|
||||||
SSLEngine on
|
SSLEngine on
|
||||||
SSLVerifyClient none
|
SSLVerifyClient none
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</Directory>
|
</Directory>
|
||||||
<Directory %sdocroot%>
|
<Directory %sdocroot%>
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
Options +Includes -Indexes +ExecCGI
|
Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
|
||||||
</Directory>
|
</Directory>
|
||||||
# <IfModule mod_ruid2.c>
|
# <IfModule mod_ruid2.c>
|
||||||
# RMode config
|
# RMode config
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<Directory %sdocroot%>
|
<Directory %sdocroot%>
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
SSLRequireSSL
|
SSLRequireSSL
|
||||||
Options +Includes -Indexes +ExecCGI
|
Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
|
||||||
</Directory>
|
</Directory>
|
||||||
SSLEngine on
|
SSLEngine on
|
||||||
SSLVerifyClient none
|
SSLVerifyClient none
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</Directory>
|
</Directory>
|
||||||
<Directory %sdocroot%>
|
<Directory %sdocroot%>
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
Options +Includes -Indexes +ExecCGI
|
Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
|
||||||
</Directory>
|
</Directory>
|
||||||
# <IfModule mod_ruid2.c>
|
# <IfModule mod_ruid2.c>
|
||||||
# RMode config
|
# RMode config
|
||||||
|
|
|
@ -24,7 +24,7 @@ PurgeLogFile=0
|
||||||
ArchiveLogRecords=0
|
ArchiveLogRecords=0
|
||||||
KeepBackupOfHistoricFiles=1
|
KeepBackupOfHistoricFiles=1
|
||||||
DefaultFile="index.php index.html"
|
DefaultFile="index.php index.html"
|
||||||
SkipHosts="127.0.0.1
|
SkipHosts="127.0.0.1"
|
||||||
SkipUserAgents=""
|
SkipUserAgents=""
|
||||||
SkipFiles=""
|
SkipFiles=""
|
||||||
SkipReferrersBlackList=""
|
SkipReferrersBlackList=""
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Changing public_html permission
|
# Changing public_html permission
|
||||||
user="$1"
|
user="$1"
|
||||||
domain="$2"
|
domain="$2"
|
||||||
ip="$3"
|
ip="$3"
|
||||||
home_dir="$4"
|
home_dir="$4"
|
||||||
docroot="$5"
|
docroot="$5"
|
||||||
|
|
||||||
chmod 755 $docroot
|
chmod 755 $docroot
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
|
@ -1,2 +1 @@
|
||||||
bl.spamcop.net
|
bl.spamcop.net
|
||||||
zen.spamhaus.org
|
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
disable_ipv6=true
|
disable_ipv6=true
|
||||||
add_environment=<; PATH=/bin:/usr/bin
|
add_environment=<; PATH=/bin:/usr/bin
|
||||||
keep_environment=
|
keep_environment=
|
||||||
|
smtputf8_advertise_hosts =
|
||||||
|
|
||||||
domainlist local_domains = dsearch;/etc/exim4/domains/
|
domainlist local_domains = dsearch;/etc/exim4/domains/
|
||||||
domainlist relay_to_domains = dsearch;/etc/exim4/domains/
|
domainlist relay_to_domains = dsearch;/etc/exim4/domains/
|
||||||
|
@ -91,16 +92,18 @@ acl_check_mail:
|
||||||
deny condition = ${if eq{$sender_helo_name}{}}
|
deny condition = ${if eq{$sender_helo_name}{}}
|
||||||
message = HELO required before MAIL
|
message = HELO required before MAIL
|
||||||
|
|
||||||
drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
|
drop !authenticated = *
|
||||||
|
message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
|
||||||
condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
|
condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
|
||||||
condition = ${if match{${lc:$sender_host_name}}{.telenor.rs}{false}{true}}
|
|
||||||
condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
|
condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
|
||||||
delay = 45s
|
delay = 45s
|
||||||
|
|
||||||
drop condition = ${if isip{$sender_helo_name}}
|
drop !authenticated = *
|
||||||
|
condition = ${if isip{$sender_helo_name}}
|
||||||
message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
|
message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
|
||||||
|
|
||||||
drop condition = ${if eq{[$interface_address]}{$sender_helo_name}}
|
drop !authenticated = *
|
||||||
|
condition = ${if eq{[$interface_address]}{$sender_helo_name}}
|
||||||
message = $interface_address is _my_ address
|
message = $interface_address is _my_ address
|
||||||
|
|
||||||
accept
|
accept
|
||||||
|
@ -319,7 +322,7 @@ remote_smtp:
|
||||||
dkim_private_key = DKIM_PRIVATE_KEY
|
dkim_private_key = DKIM_PRIVATE_KEY
|
||||||
dkim_canon = relaxed
|
dkim_canon = relaxed
|
||||||
dkim_strict = 0
|
dkim_strict = 0
|
||||||
hosts_try_fastopen = !*.l.google.com
|
hosts_try_fastopen =
|
||||||
hosts_try_chunking = !93.188.3.0/24
|
hosts_try_chunking = !93.188.3.0/24
|
||||||
|
|
||||||
procmail:
|
procmail:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
disable_ipv6=true
|
disable_ipv6=true
|
||||||
add_environment=<; PATH=/bin:/usr/bin
|
add_environment=<; PATH=/bin:/usr/bin
|
||||||
keep_environment=
|
keep_environment=
|
||||||
|
smtputf8_advertise_hosts =
|
||||||
|
|
||||||
#local_interfaces = 0.0.0.0
|
#local_interfaces = 0.0.0.0
|
||||||
#smtp_active_hostname = ${lookup{$interface_address}lsearch{/etc/exim4/virtual/helo_data}{$value}}
|
#smtp_active_hostname = ${lookup{$interface_address}lsearch{/etc/exim4/virtual/helo_data}{$value}}
|
||||||
|
@ -108,16 +109,18 @@ acl_check_mail:
|
||||||
deny condition = ${if eq{$sender_helo_name}{}}
|
deny condition = ${if eq{$sender_helo_name}{}}
|
||||||
message = HELO required before MAIL
|
message = HELO required before MAIL
|
||||||
|
|
||||||
drop message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
|
drop !authenticated = *
|
||||||
|
message = Helo name contains a ip address (HELO was $sender_helo_name) and not is valid
|
||||||
condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
|
condition = ${if match{$sender_helo_name}{\N((\d{1,3}[.-]\d{1,3}[.-]\d{1,3}[.-]\d{1,3})|([0-9a-f]{8})|([0-9A-F]{8}))\N}{yes}{no}}
|
||||||
condition = ${if match{${lc:$sender_host_name}}{.telenor.rs}{false}{true}}
|
|
||||||
condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
|
condition = ${if match {${lookup dnsdb{>: defer_never,ptr=$sender_host_address}}\}{$sender_helo_name}{no}{yes}}
|
||||||
delay = 45s
|
delay = 45s
|
||||||
|
|
||||||
drop condition = ${if isip{$sender_helo_name}}
|
drop !authenticated = *
|
||||||
|
condition = ${if isip{$sender_helo_name}}
|
||||||
message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
|
message = Access denied - Invalid HELO name (See RFC2821 4.1.3)
|
||||||
|
|
||||||
drop condition = ${if eq{[$interface_address]}{$sender_helo_name}}
|
drop !authenticated = *
|
||||||
|
condition = ${if eq{[$interface_address]}{$sender_helo_name}}
|
||||||
message = $interface_address is _my_ address
|
message = $interface_address is _my_ address
|
||||||
|
|
||||||
accept
|
accept
|
||||||
|
@ -142,7 +145,7 @@ acl_check_rcpt:
|
||||||
|
|
||||||
warn !authenticated = *
|
warn !authenticated = *
|
||||||
hosts = !+relay_from_hosts
|
hosts = !+relay_from_hosts
|
||||||
condition = ${lookup{$local_part@$domain}lsearch{/etc/exim4/domains/$domain/aliases}{true}{false}}
|
condition = ${lookup{$local_part@$domain}lsearch{/etc/exim4/domains/${lookup{$domain}dsearch{/etc/exim4/domains/}}/aliases}{true}{false}}
|
||||||
set acl_m3 = yes
|
set acl_m3 = yes
|
||||||
|
|
||||||
deny message = Restricted characters in address
|
deny message = Restricted characters in address
|
||||||
|
@ -350,7 +353,7 @@ remote_smtp:
|
||||||
dkim_private_key = DKIM_PRIVATE_KEY
|
dkim_private_key = DKIM_PRIVATE_KEY
|
||||||
dkim_canon = relaxed
|
dkim_canon = relaxed
|
||||||
dkim_strict = 0
|
dkim_strict = 0
|
||||||
hosts_try_fastopen = !*.l.google.com
|
hosts_try_fastopen =
|
||||||
hosts_try_chunking = !93.188.3.0/24
|
hosts_try_chunking = !93.188.3.0/24
|
||||||
|
|
||||||
procmail:
|
procmail:
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<Directory %sdocroot%>
|
<Directory %sdocroot%>
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
SSLRequireSSL
|
SSLRequireSSL
|
||||||
Options +Includes -Indexes +ExecCGI
|
Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
|
||||||
</Directory>
|
</Directory>
|
||||||
SSLEngine on
|
SSLEngine on
|
||||||
SSLVerifyClient none
|
SSLVerifyClient none
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</Directory>
|
</Directory>
|
||||||
<Directory %sdocroot%>
|
<Directory %sdocroot%>
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
Options +Includes -Indexes +ExecCGI
|
Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
|
||||||
</Directory>
|
</Directory>
|
||||||
# <IfModule mod_ruid2.c>
|
# <IfModule mod_ruid2.c>
|
||||||
# RMode config
|
# RMode config
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<Directory %sdocroot%>
|
<Directory %sdocroot%>
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
SSLRequireSSL
|
SSLRequireSSL
|
||||||
Options +Includes -Indexes +ExecCGI
|
Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
|
||||||
</Directory>
|
</Directory>
|
||||||
SSLEngine on
|
SSLEngine on
|
||||||
SSLVerifyClient none
|
SSLVerifyClient none
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
</Directory>
|
</Directory>
|
||||||
<Directory %sdocroot%>
|
<Directory %sdocroot%>
|
||||||
AllowOverride All
|
AllowOverride All
|
||||||
Options +Includes -Indexes +ExecCGI
|
Options +Includes -Indexes -FollowSymLinks +SymLinksIfOwnerMatch
|
||||||
</Directory>
|
</Directory>
|
||||||
# <IfModule mod_ruid2.c>
|
# <IfModule mod_ruid2.c>
|
||||||
# RMode config
|
# RMode config
|
||||||
|
|
|
@ -24,7 +24,7 @@ PurgeLogFile=0
|
||||||
ArchiveLogRecords=0
|
ArchiveLogRecords=0
|
||||||
KeepBackupOfHistoricFiles=1
|
KeepBackupOfHistoricFiles=1
|
||||||
DefaultFile="index.php index.html"
|
DefaultFile="index.php index.html"
|
||||||
SkipHosts="127.0.0.1
|
SkipHosts="127.0.0.1"
|
||||||
SkipUserAgents=""
|
SkipUserAgents=""
|
||||||
SkipFiles=""
|
SkipFiles=""
|
||||||
SkipReferrersBlackList=""
|
SkipReferrersBlackList=""
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Changing public_html permission
|
# Changing public_html permission
|
||||||
user="$1"
|
user="$1"
|
||||||
domain="$2"
|
domain="$2"
|
||||||
ip="$3"
|
ip="$3"
|
||||||
home_dir="$4"
|
home_dir="$4"
|
||||||
docroot="$5"
|
docroot="$5"
|
||||||
|
|
||||||
chmod 755 $docroot
|
chmod 755 $docroot
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
95
install/debian/12/apache2/apache2.conf
Normal file
95
install/debian/12/apache2/apache2.conf
Normal file
|
@ -0,0 +1,95 @@
|
||||||
|
# It is split into several files forming the configuration hierarchy outlined
|
||||||
|
# below, all located in the /etc/apache2/ directory:
|
||||||
|
#
|
||||||
|
# /etc/apache2/
|
||||||
|
# |-- apache2.conf
|
||||||
|
# | `-- ports.conf
|
||||||
|
# |-- mods-enabled
|
||||||
|
# | |-- *.load
|
||||||
|
# | `-- *.conf
|
||||||
|
# |-- conf.d
|
||||||
|
# | `-- *
|
||||||
|
|
||||||
|
# Global configuration
|
||||||
|
PidFile ${APACHE_PID_FILE}
|
||||||
|
Timeout 900
|
||||||
|
ProxyTimeout 900
|
||||||
|
KeepAlive Off
|
||||||
|
MaxKeepAliveRequests 100
|
||||||
|
KeepAliveTimeout 10
|
||||||
|
|
||||||
|
<IfModule mpm_prefork_module>
|
||||||
|
StartServers 8
|
||||||
|
MinSpareServers 5
|
||||||
|
MaxSpareServers 20
|
||||||
|
ServerLimit 256
|
||||||
|
MaxClients 200
|
||||||
|
MaxRequestsPerChild 4000
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
<IfModule mpm_worker_module>
|
||||||
|
StartServers 2
|
||||||
|
MinSpareThreads 25
|
||||||
|
MaxSpareThreads 75
|
||||||
|
ThreadLimit 64
|
||||||
|
ThreadsPerChild 25
|
||||||
|
MaxClients 200
|
||||||
|
MaxRequestsPerChild 4000
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
<IfModule mpm_event_module>
|
||||||
|
StartServers 2
|
||||||
|
MinSpareThreads 25
|
||||||
|
MaxSpareThreads 75
|
||||||
|
ThreadLimit 64
|
||||||
|
ThreadsPerChild 25
|
||||||
|
MaxClients 200
|
||||||
|
MaxRequestsPerChild 4000
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
|
# These need to be set in /etc/apache2/envvars
|
||||||
|
User ${APACHE_RUN_USER}
|
||||||
|
Group ${APACHE_RUN_GROUP}
|
||||||
|
#User www-data
|
||||||
|
#Group www-data
|
||||||
|
|
||||||
|
AccessFileName .htaccess
|
||||||
|
|
||||||
|
<Files ~ "^\.ht">
|
||||||
|
Order allow,deny
|
||||||
|
Deny from all
|
||||||
|
Satisfy all
|
||||||
|
</Files>
|
||||||
|
|
||||||
|
DefaultType None
|
||||||
|
HostnameLookups Off
|
||||||
|
|
||||||
|
ErrorLog ${APACHE_LOG_DIR}/error.log
|
||||||
|
LogLevel warn
|
||||||
|
|
||||||
|
# Include module configuration:
|
||||||
|
Include mods-enabled/*.load
|
||||||
|
Include mods-enabled/*.conf
|
||||||
|
|
||||||
|
# Include list of ports to listen on and which to use for name based vhosts
|
||||||
|
Include ports.conf
|
||||||
|
|
||||||
|
LogFormat "%v:%p %h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
|
||||||
|
LogFormat "%h %l %u %t \"%r\" %>s %O \"%{Referer}i\" \"%{User-Agent}i\"" combined
|
||||||
|
LogFormat "%h %l %u %t \"%r\" %>s %O" common
|
||||||
|
LogFormat "%{Referer}i -> %U" referer
|
||||||
|
LogFormat "%{User-agent}i" agent
|
||||||
|
LogFormat "%b" bytes
|
||||||
|
|
||||||
|
Include conf.d/
|
||||||
|
|
||||||
|
# Include the virtual host configurations:
|
||||||
|
#Include sites-enabled/
|
||||||
|
|
||||||
|
ErrorDocument 403 /error/403.html
|
||||||
|
ErrorDocument 404 /error/404.html
|
||||||
|
ErrorDocument 500 /error/50x.html
|
||||||
|
ErrorDocument 501 /error/50x.html
|
||||||
|
ErrorDocument 502 /error/50x.html
|
||||||
|
ErrorDocument 503 /error/50x.html
|
||||||
|
ErrorDocument 506 /error/50x.html
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue