Skip to content

Commit 5d7e5eb

Browse files
committed
update
1 parent 37335d8 commit 5d7e5eb

File tree

2 files changed

+46
-2
lines changed

2 files changed

+46
-2
lines changed

web/Modules/Caddy/App/Jobs/CaddyBuild.php

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,13 @@
44

55
use App\MasterDomain;
66
use App\Models\Domain;
7+
use App\Models\HostingSubscription;
78
use Illuminate\Bus\Queueable;
89
use Illuminate\Contracts\Queue\ShouldQueue;
910
use Illuminate\Foundation\Bus\Dispatchable;
1011
use Illuminate\Queue\InteractsWithQueue;
1112
use Illuminate\Queue\SerializesModels;
13+
use Modules\Microweber\App\Models\MicroweberInstallation;
1214

1315
class CaddyBuild implements ShouldQueue
1416
{
@@ -197,7 +199,26 @@ protected function generateCaddyfile(): void
197199
shell_exec("sudo setfacl -R -m u:caddy:rx " . $domain->document_root);
198200
shell_exec("sudo setfacl -R -m u:caddy:rx " . $domain->domain_public);
199201
shell_exec("sudo setfacl -R -m u:caddy:rx " . $domain->home_root);
200-
//
202+
203+
204+
/* //fix permissions
205+
shell_exec('chown -R ' . $chown_user . ':' . $chown_user . ' ' . $chown_path);
206+
207+
// chmod
208+
shell_exec('chmod -R 755 ' . $chown_path);*/
209+
210+
$findHostingSubscription = HostingSubscription::where('id', $domain->id)->first();
211+
212+
$chown_user = $findHostingSubscription->system_username;
213+
214+
$chown_path = $domain->home_root;
215+
//fix permissions
216+
// shell_exec('chown -R ' . $chown_user . ':' . $chown_user . ' ' . $chown_path);
217+
218+
// chmod
219+
// shell_exec('chmod -R 755 ' . $chown_path);
220+
221+
201222

202223
// Check current permissions using getfacl
203224
// $homeRootPerms = shell_exec("getfacl " . escapeshellarg($domain->home_root));
@@ -218,6 +239,9 @@ protected function generateCaddyfile(): void
218239
shell_exec("chmod o+x {$domain->home_root}");
219240
shell_exec("chmod -R o+rX {$domain->document_root}");
220241

242+
243+
244+
221245
if (!file_exists($domainLog)) {
222246
// Create log file for the domain if it doesn't exist
223247
touch($domainLog);

web/Modules/Microweber/Listeners/DomainIsChangedListener.php

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Modules\Microweber\Listeners;
44

55
use App\Events\DomainIsChanged;
6+
use App\Models\HostingSubscription;
67
use Illuminate\Contracts\Queue\ShouldQueue;
78
use Illuminate\Queue\InteractsWithQueue;
89
use Modules\Microweber\App\Models\MicroweberInstallation;
@@ -31,8 +32,27 @@ public function handle(DomainIsChanged $event): void
3132
if (!$findMicroweberInstallation) {
3233
return;
3334
}
35+
$findHostingSubscription = HostingSubscription::where('id', $event->domain->id)->first();
36+
if (!$findHostingSubscription) {
37+
$this->info('Hosting subscription not found: ' . $event->domain->id);
38+
return;
39+
}
40+
$findInstallation = MicroweberInstallation::where('domain_id', $event->domain->id)
41+
->first();
42+
$chown_user = $findHostingSubscription->system_username;
43+
44+
$chown_path = $findMicroweberInstallation->installation_path;
45+
46+
shell_exec('php ' . $findMicroweberInstallation->installation_path . '/artisan cache:clear');
47+
48+
//fix permissions
49+
shell_exec('chown -R ' . $chown_user . ':' . $chown_user . ' ' . $chown_path);
50+
51+
// chmod
52+
shell_exec('chmod -R 755 ' . $chown_path);
53+
54+
3455

35-
shell_exec('php '. $findMicroweberInstallation->installation_path . '/artisan cache:clear');
3656

3757
}
3858
}

0 commit comments

Comments
 (0)