- package updates

- feat: service fixes
- ui: help menu
This commit is contained in:
Andras Bacsai
2023-09-25 12:49:55 +02:00
parent 356394c03d
commit 58522b59b7
28 changed files with 973 additions and 679 deletions

View File

@@ -1,6 +1,8 @@
<?php
use App\Models\Service;
use App\Models\ServiceApplication;
use App\Models\ServiceDatabase;
use Illuminate\Support\Str;
function replaceRegex(?string $name = null)
@@ -43,4 +45,32 @@ function serviceStatus(Service $service)
} else if (!$foundRunning && $isDegraded) {
return 'exited';
}
return 'exited';
}
function saveFileVolumesHelper(ServiceApplication|ServiceDatabase $oneService)
{
try {
$workdir = $oneService->service->workdir();
$server = $oneService->service->server;
$applicationFileVolume = $oneService->fileStorages()->get();
$commands = collect([
"mkdir -p $workdir",
"cd $workdir"
]);
foreach ($applicationFileVolume as $fileVolume) {
$content = $fileVolume->content;
$path = Str::of($fileVolume->fs_path);
$dir = $path->beforeLast('/');
if ($dir->startsWith('.')) {
$dir = $dir->after('.');
$dir = $workdir . $dir;
}
$content = base64_encode($content);
$commands->push("mkdir -p $dir");
$commands->push("echo '$content' | base64 -d > $path");
}
return instant_remote_process($commands, $server);
} catch (\Throwable $e) {
return handleError($e);
}
}