Fix filemanager permissions (#508)

* Fix filemanager permissions

* fix filemanager permissions

* fix tests warning
This commit is contained in:
Saeed Vaziry
2025-02-26 20:46:07 +01:00
committed by GitHub
parent e17fdbb1a0
commit 3bf3f7eebc
12 changed files with 56 additions and 55 deletions

View File

@ -3,14 +3,9 @@
namespace App\SSH\OS;
use App\Exceptions\SSHError;
use App\Exceptions\SSHUploadFailed;
use App\Models\Server;
use App\Models\ServerLog;
use App\Models\Site;
use Illuminate\Filesystem\FilesystemAdapter;
use Illuminate\Support\Facades\Storage;
use Illuminate\Support\Str;
use Throwable;
class OS
{
@ -178,27 +173,8 @@ public function reboot(): void
}
/**
* @throws SSHUploadFailed
*/
public function editFile(string $path, ?string $content = null): void
{
$tmpName = Str::random(10).strtotime('now');
try {
/** @var FilesystemAdapter $storageDisk */
$storageDisk = Storage::disk('local');
$storageDisk->put($tmpName, $content);
$this->server->ssh()->upload(
$storageDisk->path($tmpName),
$path
);
} catch (Throwable) {
throw new SSHUploadFailed;
} finally {
$this->deleteTempFile($tmpName);
}
}
/**
* @deprecated use write() instead
*
* @throws SSHError
*/
public function editFileAs(string $path, string $user, ?string $content = null): void
@ -349,9 +325,10 @@ public function ls(string $path, ?string $user = null): string
*/
public function write(string $path, string $content, ?string $user = null): void
{
$this->server->ssh($user)->write(
$this->server->ssh()->write(
$path,
$content
$content,
$user
);
}
@ -362,11 +339,4 @@ public function mkdir(string $path, ?string $user = null): string
{
return $this->server->ssh($user)->exec('mkdir -p '.$path);
}
private function deleteTempFile(string $name): void
{
if (Storage::disk('local')->exists($name)) {
Storage::disk('local')->delete($name);
}
}
}

View File

@ -135,7 +135,7 @@ public function createFpmPool(string $user, string $version, $site_id): void
'user' => $user,
'version' => $version,
]),
true
'root'
);
$this->service->server->systemd()->restart($this->service->unit);

View File

@ -55,7 +55,7 @@ public function create(
'numprocs' => (string) $numprocs,
'logFile' => $logFile,
]),
true
'root'
);
$this->service->server->ssh()->exec(

View File

@ -26,7 +26,7 @@ public function install(): void
view('ssh.services.webserver.nginx.nginx', [
'user' => $this->service->server->getSshUser(),
]),
true
'root'
);
$this->service->server->systemd()->restart('nginx');
@ -83,7 +83,7 @@ public function createVHost(Site $site): void
view('ssh.services.webserver.nginx.vhost', [
'site' => $site,
]),
true
'root'
);
$this->service->server->ssh()->exec(
@ -108,7 +108,7 @@ public function updateVHost(Site $site, ?string $vhost = null): void
$vhost ?? view('ssh.services.webserver.nginx.vhost', [
'site' => $site,
]),
true
'root'
);
$this->service->server->systemd()->restart('nginx');