-
Notifications
You must be signed in to change notification settings - Fork 222
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from vitodeploy/phpmyadmin
add phpmyadmin
- Loading branch information
Showing
58 changed files
with
432 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace App\Actions\Service; | ||
|
||
use App\Enums\ServiceStatus; | ||
use App\Models\Server; | ||
use App\Models\Service; | ||
use Illuminate\Support\Facades\Validator; | ||
use Illuminate\Validation\Rule; | ||
|
||
class Create | ||
{ | ||
public function create(Server $server, array $input): Service | ||
{ | ||
$this->validate($server, $input); | ||
|
||
$service = new Service([ | ||
'name' => $input['type'], | ||
'type' => $input['type'], | ||
'version' => $input['version'], | ||
'status' => ServiceStatus::INSTALLING, | ||
]); | ||
|
||
Validator::make($input, $service->handler()->creationRules($input))->validate(); | ||
|
||
$service->type_data = $service->handler()->creationData($input); | ||
|
||
$service->save(); | ||
|
||
$service->handler()->create(); | ||
|
||
dispatch(function () use ($service) { | ||
$service->handler()->install(); | ||
$service->status = ServiceStatus::READY; | ||
$service->save(); | ||
})->catch(function () use ($service) { | ||
$service->handler()->delete(); | ||
$service->delete(); | ||
})->onConnection('ssh'); | ||
|
||
return $service; | ||
} | ||
|
||
private function validate(Server $server, array $input): void | ||
{ | ||
Validator::make($input, [ | ||
'type' => [ | ||
'required', | ||
Rule::in(config('core.add_on_services')), | ||
Rule::unique('services', 'type')->where('server_id', $server->id), | ||
], | ||
'version' => 'required', | ||
])->validate(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
if ! wget __url__ -O __path__; then | ||
echo 'VITO_SSH_ERROR' && exit 1 | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace App\SSH\PHPMyAdmin; | ||
|
||
use App\Models\Site; | ||
use App\SSH\HasScripts; | ||
|
||
class PHPMyAdmin | ||
{ | ||
use HasScripts; | ||
|
||
public function install(Site $site): void | ||
{ | ||
$site->server->ssh()->exec( | ||
$this->getScript('install.sh', [ | ||
'version' => $site->type_data['version'], | ||
'path' => $site->path, | ||
]), | ||
'install-phpmyadmin', | ||
$site->id | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
sudo rm -rf phpmyadmin | ||
|
||
sudo rm -rf __path__ | ||
|
||
if ! wget https://files.phpmyadmin.net/phpMyAdmin/__version__/phpMyAdmin-__version__-all-languages.zip; then | ||
echo 'VITO_SSH_ERROR' && exit 1 | ||
fi | ||
|
||
if ! unzip phpMyAdmin-__version__-all-languages.zip; then | ||
echo 'VITO_SSH_ERROR' && exit 1 | ||
fi | ||
|
||
if ! rm -rf phpMyAdmin-__version__-all-languages.zip; then | ||
echo 'VITO_SSH_ERROR' && exit 1 | ||
fi | ||
|
||
if ! mv phpMyAdmin-__version__-all-languages __path__; then | ||
echo 'VITO_SSH_ERROR' && exit 1 | ||
fi | ||
|
||
if ! mv __path__/config.sample.inc.php __path__/config.inc.php; then | ||
echo 'VITO_SSH_ERROR' && exit 1 | ||
fi | ||
|
||
echo "PHPMyAdmin installed!" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\SSH\Services\AddOnServices; | ||
|
||
use App\SSH\Services\ServiceInterface; | ||
|
||
abstract class AbstractAddOnService implements ServiceInterface | ||
{ | ||
abstract public function creationRules(array $input): array; | ||
|
||
abstract public function creationData(array $input): array; | ||
|
||
abstract public function create(): void; | ||
|
||
abstract public function delete(): void; | ||
|
||
abstract public function data(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace App\SiteTypes; | ||
|
||
use Illuminate\Validation\Rule; | ||
|
||
class PHPMyAdmin extends PHPSite | ||
{ | ||
public function supportedFeatures(): array | ||
{ | ||
return [ | ||
// | ||
]; | ||
} | ||
|
||
public function createRules(array $input): array | ||
{ | ||
return [ | ||
'php_version' => [ | ||
'required', | ||
Rule::in($this->site->server->installedPHPVersions()), | ||
], | ||
'version' => 'required|string', | ||
]; | ||
} | ||
|
||
public function createFields(array $input): array | ||
{ | ||
return [ | ||
'web_directory' => '', | ||
'php_version' => $input['php_version'] ?? '', | ||
]; | ||
} | ||
|
||
public function data(array $input): array | ||
{ | ||
return [ | ||
'version' => $input['version'], | ||
]; | ||
} | ||
|
||
public function install(): void | ||
{ | ||
$this->site->server->webserver()->handler()->createVHost($this->site); | ||
$this->progress(30); | ||
app(\App\SSH\PHPMyAdmin\PHPMyAdmin::class)->install($this->site); | ||
$this->progress(65); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<div> | ||
<x-simple-card class="flex items-center justify-between"> | ||
<span>PHPMyAdmin is installed and ready to use!</span> | ||
<x-secondary-button :href="$site->getUrl()" target="_blank">Open</x-secondary-button> | ||
</x-simple-card> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.