mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 18:01:37 +00:00
Merge (#127)
This commit is contained in:
parent
884f18db63
commit
4d051330d6
24
.env.example
24
.env.example
@ -2,28 +2,9 @@ APP_NAME=Vito
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://vito.test
|
||||
APP_URL=
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=vito
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=null
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=default
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=
|
||||
@ -33,6 +14,3 @@ MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
SSH_PUBLIC_KEY_NAME=ssh-public.key
|
||||
SSH_PRIVATE_KEY_NAME=ssh-private.pem
|
||||
|
22
.env.prod
22
.env.prod
@ -4,26 +4,7 @@ APP_KEY=
|
||||
APP_DEBUG=false
|
||||
APP_URL=
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=
|
||||
DB_USERNAME=
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=null
|
||||
CACHE_DRIVER=file
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=default
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=127.0.0.1
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=
|
||||
@ -33,6 +14,3 @@ MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
SSH_PUBLIC_KEY_NAME=ssh-public.key
|
||||
SSH_PRIVATE_KEY_NAME=ssh-private.pem
|
||||
|
32
.env.sail
32
.env.sail
@ -2,28 +2,10 @@ APP_NAME=Vito
|
||||
APP_ENV=local
|
||||
APP_KEY=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://vito.test
|
||||
APP_URL=
|
||||
APP_PORT=8000
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=mysql
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=vito
|
||||
DB_USERNAME=sail
|
||||
DB_PASSWORD=password
|
||||
|
||||
BROADCAST_DRIVER=null
|
||||
CACHE_DRIVER=redis
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=default
|
||||
SESSION_DRIVER=database
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
REDIS_HOST=redis
|
||||
REDIS_PASSWORD=null
|
||||
REDIS_PORT=6379
|
||||
|
||||
MAIL_MAILER=smtp
|
||||
MAIL_HOST=
|
||||
@ -33,13 +15,3 @@ MAIL_PASSWORD=null
|
||||
MAIL_ENCRYPTION=null
|
||||
MAIL_FROM_ADDRESS=null
|
||||
MAIL_FROM_NAME="${APP_NAME}"
|
||||
|
||||
SSH_PUBLIC_KEY_NAME=ssh-public.key
|
||||
SSH_PRIVATE_KEY_NAME=ssh-private.pem
|
||||
|
||||
APP_SERVICE=vito
|
||||
|
||||
FORWARD_REDIS_PORT=2060
|
||||
FORWARD_DB_PORT=2070
|
||||
APP_PORT=2080
|
||||
HMR_PORT=2090
|
||||
|
27
.env.testing
27
.env.testing
@ -1,27 +0,0 @@
|
||||
APP_NAME=Vito
|
||||
APP_ENV=local
|
||||
APP_KEY=base64:d9kZW60V4lFEw2SPn6UiJ0cfi04v80EWP0GZ6kzoxNg=
|
||||
APP_DEBUG=true
|
||||
APP_URL=http://localhost:2080
|
||||
|
||||
LOG_CHANNEL=stack
|
||||
LOG_LEVEL=debug
|
||||
|
||||
DB_CONNECTION=mysql
|
||||
DB_HOST=127.0.0.1
|
||||
DB_PORT=3306
|
||||
DB_DATABASE=vito_test
|
||||
DB_USERNAME=root
|
||||
DB_PASSWORD=
|
||||
|
||||
BROADCAST_DRIVER=null
|
||||
CACHE_DRIVER=array
|
||||
FILESYSTEM_DRIVER=local
|
||||
QUEUE_CONNECTION=database
|
||||
SESSION_DRIVER=array
|
||||
SESSION_LIFETIME=120
|
||||
|
||||
MAIL_MAILER=array
|
||||
|
||||
SSH_PUBLIC_KEY_NAME=ssh-public.key
|
||||
SSH_PRIVATE_KEY_NAME=ssh-private.pem
|
19
.github/workflows/code-style.yml
vendored
19
.github/workflows/code-style.yml
vendored
@ -2,9 +2,9 @@ name: code-style
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 1.x
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
jobs:
|
||||
code-style:
|
||||
@ -13,7 +13,8 @@ jobs:
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [ 8.1 ]
|
||||
php: [8.2]
|
||||
node-version: ["20.x"]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -31,9 +32,21 @@ jobs:
|
||||
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-php-
|
||||
|
||||
- name: Install dependencies
|
||||
if: steps.composer-cache.outputs.cache-hit != 'true'
|
||||
run: composer install --prefer-dist --no-progress --no-suggest
|
||||
|
||||
- name: Run pint
|
||||
run: ./vendor/bin/pint --test
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: "20.x"
|
||||
|
||||
- name: Install NPM Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Run lint
|
||||
run: npm run lint
|
||||
|
26
.github/workflows/tests.yml
vendored
26
.github/workflows/tests.yml
vendored
@ -2,30 +2,18 @@ name: tests
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 1.x
|
||||
pull_request:
|
||||
schedule:
|
||||
- cron: '0 0 * * *'
|
||||
|
||||
jobs:
|
||||
tests:
|
||||
runs-on: ubuntu-22.04
|
||||
|
||||
services:
|
||||
mysql:
|
||||
image: mysql
|
||||
env:
|
||||
MYSQL_DATABASE: test_db
|
||||
MYSQL_USER: user
|
||||
MYSQL_PASSWORD: password
|
||||
MYSQL_ROOT_PASSWORD: rootpassword
|
||||
ports:
|
||||
- 3306:3306
|
||||
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
|
||||
|
||||
strategy:
|
||||
fail-fast: true
|
||||
matrix:
|
||||
php: [ 8.1 ]
|
||||
php: [8.2]
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
@ -47,10 +35,8 @@ jobs:
|
||||
if: steps.composer-cache.outputs.cache-hit != 'true'
|
||||
run: composer install --prefer-dist --no-progress --no-suggest
|
||||
|
||||
- name: Create sqlite database
|
||||
run: touch storage/database-test.sqlite
|
||||
|
||||
- name: Run test suite
|
||||
run: php artisan test
|
||||
env:
|
||||
DB_HOST: 127.0.0.1
|
||||
DB_DATABASE: test_db
|
||||
DB_USERNAME: user
|
||||
DB_PASSWORD: password
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -4,6 +4,8 @@
|
||||
/public/storage
|
||||
/storage/*.key
|
||||
/storage/*.pem
|
||||
/storage/test-key
|
||||
/storage/test-key.pub
|
||||
/vendor
|
||||
.env
|
||||
.env.backup
|
||||
|
16
.prettierrc
Normal file
16
.prettierrc
Normal file
@ -0,0 +1,16 @@
|
||||
{
|
||||
"plugins": ["prettier-plugin-blade", "prettier-plugin-tailwindcss"],
|
||||
"overrides": [
|
||||
{
|
||||
"files": ["*.blade.php"],
|
||||
"options": {
|
||||
"parser": "blade",
|
||||
"printWidth": 120,
|
||||
"htmlWhitespaceSensitivity": "ignore",
|
||||
"tabWidth": 4,
|
||||
"quoteProps": "consistent",
|
||||
"trailingComma": "none"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
24
README.md
24
README.md
@ -11,6 +11,12 @@ ## About Vito
|
||||
|
||||
Vito is a self-hosted web application that helps you manage your servers and deploy your PHP applications into production servers without a hassle.
|
||||
|
||||
## Quick Start
|
||||
|
||||
```sh
|
||||
bash <(curl -Ls https://raw.githubusercontent.com/vitodeploy/vito/1.x/scripts/install.sh)
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
- Provisions and Manages the server
|
||||
@ -38,15 +44,13 @@ ## Useful Links
|
||||
## Credits
|
||||
|
||||
- Laravel
|
||||
- Tailwindcss
|
||||
- Livewire
|
||||
- Alpinejs
|
||||
- Vite
|
||||
- Laravel Enum by BenSampo
|
||||
- Log Viewer by Arunas Skirius
|
||||
- PHPSecLib
|
||||
- Laravel Blade Icons
|
||||
- Guzzlehttp
|
||||
- Owenvoke for `owenvoke/blade-fontawesome`
|
||||
- Axios
|
||||
- PHPUnit
|
||||
- Tailwindcss
|
||||
- Alpinejs
|
||||
- HTMX
|
||||
- Vite
|
||||
- Toastr by CodeSeven
|
||||
- Prettier
|
||||
- Postcss
|
||||
- Flowbite
|
||||
|
@ -3,8 +3,9 @@ # Security Policy
|
||||
## Supported Versions
|
||||
|
||||
| Version | Supported |
|
||||
| ------- | ------------------ |
|
||||
| 0.x | :white_check_mark: |
|
||||
| ------- | ----------|
|
||||
| 0.x | ❌ |
|
||||
| 1.x | ✅ |
|
||||
|
||||
## Reporting a Vulnerability
|
||||
|
||||
|
@ -19,11 +19,14 @@ public function create(Server $server, array $input): void
|
||||
'server_id' => $server->id,
|
||||
'user' => $input['user'],
|
||||
'command' => $input['command'],
|
||||
'frequency' => $input['frequency'],
|
||||
'frequency' => $input['frequency'] == 'custom' ? $input['custom'] : $input['frequency'],
|
||||
'status' => CronjobStatus::CREATING,
|
||||
]);
|
||||
$cronJob->save();
|
||||
$cronJob->addToServer();
|
||||
|
||||
$server->cron()->update($cronJob->user, CronJob::crontab($server, $cronJob->user));
|
||||
$cronJob->status = CronjobStatus::READY;
|
||||
$cronJob->save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,9 +43,18 @@ private function validate(array $input): void
|
||||
'in:root,'.config('core.ssh_user'),
|
||||
],
|
||||
'frequency' => [
|
||||
'required',
|
||||
new CronRule(acceptCustom: true),
|
||||
],
|
||||
])->validate();
|
||||
|
||||
if ($input['frequency'] == 'custom') {
|
||||
Validator::make($input, [
|
||||
'custom' => [
|
||||
'required',
|
||||
new CronRule(),
|
||||
],
|
||||
])->validateWithBag('createCronJob');
|
||||
])->validate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
16
app/Actions/CronJob/DeleteCronJob.php
Executable file
16
app/Actions/CronJob/DeleteCronJob.php
Executable file
@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\CronJob;
|
||||
|
||||
use App\Models\CronJob;
|
||||
use App\Models\Server;
|
||||
|
||||
class DeleteCronJob
|
||||
{
|
||||
public function delete(Server $server, CronJob $cronJob): void
|
||||
{
|
||||
$user = $cronJob->user;
|
||||
$cronJob->delete();
|
||||
$server->cron()->update($cronJob->user, CronJob::crontab($server, $user));
|
||||
}
|
||||
}
|
@ -24,15 +24,15 @@ public function create($type, Server $server, array $input): Backup
|
||||
$backup = new Backup([
|
||||
'type' => $type,
|
||||
'server_id' => $server->id,
|
||||
'database_id' => $input['database'] ?? null,
|
||||
'storage_id' => $input['storage'],
|
||||
'interval' => $input['interval'] == 'custom' ? $input['custom'] : $input['interval'],
|
||||
'keep_backups' => $input['keep'],
|
||||
'database_id' => $input['backup_database'] ?? null,
|
||||
'storage_id' => $input['backup_storage'],
|
||||
'interval' => $input['backup_interval'] == 'custom' ? $input['backup_custom'] : $input['backup_interval'],
|
||||
'keep_backups' => $input['backup_keep'],
|
||||
'status' => BackupStatus::RUNNING,
|
||||
]);
|
||||
$backup->save();
|
||||
|
||||
$backup->run();
|
||||
app(RunBackup::class)->run($backup);
|
||||
|
||||
return $backup;
|
||||
}
|
||||
@ -43,16 +43,16 @@ public function create($type, Server $server, array $input): Backup
|
||||
private function validate($type, Server $server, array $input): void
|
||||
{
|
||||
$rules = [
|
||||
'storage' => [
|
||||
'backup_storage' => [
|
||||
'required',
|
||||
Rule::exists('storage_providers', 'id'),
|
||||
],
|
||||
'keep' => [
|
||||
'backup_keep' => [
|
||||
'required',
|
||||
'numeric',
|
||||
'min:1',
|
||||
],
|
||||
'interval' => [
|
||||
'backup_interval' => [
|
||||
'required',
|
||||
Rule::in([
|
||||
'0 * * * *',
|
||||
@ -63,13 +63,13 @@ private function validate($type, Server $server, array $input): void
|
||||
]),
|
||||
],
|
||||
];
|
||||
if ($input['interval'] == 'custom') {
|
||||
$rules['custom'] = [
|
||||
if ($input['backup_interval'] == 'custom') {
|
||||
$rules['backup_custom'] = [
|
||||
'required',
|
||||
];
|
||||
}
|
||||
if ($type === 'database') {
|
||||
$rules['database'] = [
|
||||
$rules['backup_database'] = [
|
||||
'required',
|
||||
Rule::exists('databases', 'id')
|
||||
->where('server_id', $server->id)
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Actions\Database;
|
||||
|
||||
use App\Enums\DatabaseStatus;
|
||||
use App\Models\Database;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@ -21,8 +22,9 @@ public function create(Server $server, array $input): Database
|
||||
'server_id' => $server->id,
|
||||
'name' => $input['name'],
|
||||
]);
|
||||
$server->database()->handler()->create($database->name);
|
||||
$database->status = DatabaseStatus::READY;
|
||||
$database->save();
|
||||
$database->createOnServer();
|
||||
|
||||
return $database;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Actions\Database;
|
||||
|
||||
use App\Enums\DatabaseUserStatus;
|
||||
use App\Models\DatabaseUser;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
@ -24,8 +25,17 @@ public function create(Server $server, array $input, array $links = []): Databas
|
||||
'host' => isset($input['remote']) && $input['remote'] ? $input['host'] : 'localhost',
|
||||
'databases' => $links,
|
||||
]);
|
||||
$server->database()->handler()->createUser(
|
||||
$databaseUser->username,
|
||||
$databaseUser->password,
|
||||
$databaseUser->host
|
||||
);
|
||||
$databaseUser->status = DatabaseUserStatus::READY;
|
||||
$databaseUser->save();
|
||||
$databaseUser->createOnServer();
|
||||
|
||||
if (count($links) > 0) {
|
||||
app(LinkUser::class)->link($databaseUser, ['databases' => $links]);
|
||||
}
|
||||
|
||||
return $databaseUser;
|
||||
}
|
||||
|
15
app/Actions/Database/DeleteDatabase.php
Executable file
15
app/Actions/Database/DeleteDatabase.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Database;
|
||||
|
||||
use App\Models\Database;
|
||||
use App\Models\Server;
|
||||
|
||||
class DeleteDatabase
|
||||
{
|
||||
public function delete(Server $server, Database $database): void
|
||||
{
|
||||
$server->database()->handler()->delete($database->name);
|
||||
$database->delete();
|
||||
}
|
||||
}
|
15
app/Actions/Database/DeleteDatabaseUser.php
Executable file
15
app/Actions/Database/DeleteDatabaseUser.php
Executable file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Database;
|
||||
|
||||
use App\Models\DatabaseUser;
|
||||
use App\Models\Server;
|
||||
|
||||
class DeleteDatabaseUser
|
||||
{
|
||||
public function delete(Server $server, DatabaseUser $databaseUser): void
|
||||
{
|
||||
$server->database()->handler()->deleteUser($databaseUser->username, $databaseUser->host);
|
||||
$databaseUser->delete();
|
||||
}
|
||||
}
|
@ -4,6 +4,9 @@
|
||||
|
||||
use App\Models\Database;
|
||||
use App\Models\DatabaseUser;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class LinkUser
|
||||
@ -11,20 +14,49 @@ class LinkUser
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function link(DatabaseUser $databaseUser, array $databases): void
|
||||
public function link(DatabaseUser $databaseUser, array $input): void
|
||||
{
|
||||
$dbs = Database::query()
|
||||
->where('server_id', $databaseUser->server_id)
|
||||
->whereIn('name', $databases)
|
||||
->count();
|
||||
if (count($databases) !== $dbs) {
|
||||
throw ValidationException::withMessages(['databases' => __('Databases not found!')])
|
||||
->errorBag('linkUser');
|
||||
if (! isset($input['databases']) || ! is_array($input['databases'])) {
|
||||
$input['databases'] = [];
|
||||
}
|
||||
|
||||
$databaseUser->databases = $databases;
|
||||
$databaseUser->unlinkUser();
|
||||
$databaseUser->linkUser();
|
||||
$this->validate($databaseUser->server, $input);
|
||||
|
||||
$dbs = Database::query()
|
||||
->where('server_id', $databaseUser->server_id)
|
||||
->whereIn('name', $input['databases'])
|
||||
->count();
|
||||
if (count($input['databases']) !== $dbs) {
|
||||
throw ValidationException::withMessages(['databases' => __('Databases not found!')]);
|
||||
}
|
||||
|
||||
$databaseUser->databases = $input['databases'];
|
||||
|
||||
// Unlink the user from all databases
|
||||
$databaseUser->server->database()->handler()->unlink(
|
||||
$databaseUser->username,
|
||||
$databaseUser->host
|
||||
);
|
||||
|
||||
// Link the user to the selected databases
|
||||
$databaseUser->server->database()->handler()->link(
|
||||
$databaseUser->username,
|
||||
$databaseUser->host,
|
||||
$databaseUser->databases
|
||||
);
|
||||
|
||||
$databaseUser->save();
|
||||
}
|
||||
|
||||
private function validate(Server $server, array $input): void
|
||||
{
|
||||
$rules = [
|
||||
'databases.*' => [
|
||||
'required',
|
||||
Rule::exists('databases', 'name')->where('server_id', $server->id),
|
||||
],
|
||||
];
|
||||
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
}
|
||||
|
39
app/Actions/Database/RestoreBackup.php
Normal file
39
app/Actions/Database/RestoreBackup.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Database;
|
||||
|
||||
use App\Enums\BackupFileStatus;
|
||||
use App\Models\BackupFile;
|
||||
use App\Models\Database;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
|
||||
class RestoreBackup
|
||||
{
|
||||
public function restore(BackupFile $backupFile, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
/** @var Database $database */
|
||||
$database = Database::query()->findOrFail($input['database']);
|
||||
$backupFile->status = BackupFileStatus::RESTORING;
|
||||
$backupFile->restored_to = $database->name;
|
||||
$backupFile->save();
|
||||
|
||||
dispatch(function () use ($backupFile, $database) {
|
||||
$database->server->database()->handler()->restoreBackup($backupFile, $database->name);
|
||||
$backupFile->status = BackupFileStatus::RESTORED;
|
||||
$backupFile->restored_at = now();
|
||||
$backupFile->save();
|
||||
})->catch(function () use ($backupFile) {
|
||||
$backupFile->status = BackupFileStatus::RESTORE_FAILED;
|
||||
$backupFile->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
private function validate(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'database' => 'required|exists:databases,id',
|
||||
])->validate();
|
||||
}
|
||||
}
|
32
app/Actions/Database/RunBackup.php
Normal file
32
app/Actions/Database/RunBackup.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Database;
|
||||
|
||||
use App\Enums\BackupFileStatus;
|
||||
use App\Models\Backup;
|
||||
use App\Models\BackupFile;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class RunBackup
|
||||
{
|
||||
public function run(Backup $backup): BackupFile
|
||||
{
|
||||
$file = new BackupFile([
|
||||
'backup_id' => $backup->id,
|
||||
'name' => Str::of($backup->database->name)->slug().'-'.now()->format('YmdHis'),
|
||||
'status' => BackupFileStatus::CREATING,
|
||||
]);
|
||||
$file->save();
|
||||
|
||||
dispatch(function () use ($file) {
|
||||
$file->backup->server->database()->handler()->runBackup($file);
|
||||
$file->status = BackupFileStatus::CREATED;
|
||||
$file->save();
|
||||
})->catch(function () use ($file) {
|
||||
$file->status = BackupFileStatus::FAILED;
|
||||
$file->save();
|
||||
})->onConnection('ssh');
|
||||
|
||||
return $file;
|
||||
}
|
||||
}
|
@ -21,10 +21,20 @@ public function create(Server $server, array $input): FirewallRule
|
||||
'port' => $input['port'],
|
||||
'source' => $input['source'],
|
||||
'mask' => $input['mask'] ?? null,
|
||||
'status' => FirewallRuleStatus::CREATING,
|
||||
]);
|
||||
|
||||
$server->firewall()
|
||||
->handler()
|
||||
->addRule(
|
||||
$rule->type,
|
||||
$rule->getRealProtocol(),
|
||||
$rule->port,
|
||||
$rule->source,
|
||||
$rule->mask
|
||||
);
|
||||
|
||||
$rule->status = FirewallRuleStatus::READY;
|
||||
$rule->save();
|
||||
$rule->addToServer();
|
||||
|
||||
return $rule;
|
||||
}
|
||||
@ -56,6 +66,6 @@ private function validate(Server $server, array $input): void
|
||||
'mask' => [
|
||||
'numeric',
|
||||
],
|
||||
])->validateWithBag('createRule');
|
||||
])->validate();
|
||||
}
|
||||
}
|
||||
|
28
app/Actions/FirewallRule/DeleteRule.php
Executable file
28
app/Actions/FirewallRule/DeleteRule.php
Executable file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\FirewallRule;
|
||||
|
||||
use App\Enums\FirewallRuleStatus;
|
||||
use App\Models\FirewallRule;
|
||||
use App\Models\Server;
|
||||
|
||||
class DeleteRule
|
||||
{
|
||||
public function delete(Server $server, FirewallRule $rule): void
|
||||
{
|
||||
$rule->status = FirewallRuleStatus::DELETING;
|
||||
$rule->save();
|
||||
|
||||
$server->firewall()
|
||||
->handler()
|
||||
->removeRule(
|
||||
$rule->type,
|
||||
$rule->getRealProtocol(),
|
||||
$rule->port,
|
||||
$rule->source,
|
||||
$rule->mask
|
||||
);
|
||||
|
||||
$rule->delete();
|
||||
}
|
||||
}
|
29
app/Actions/PHP/ChangeDefaultCli.php
Normal file
29
app/Actions/PHP/ChangeDefaultCli.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\PHP;
|
||||
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class ChangeDefaultCli
|
||||
{
|
||||
public function change(Server $server, array $input): void
|
||||
{
|
||||
$this->validate($server, $input);
|
||||
$service = $server->php($input['version']);
|
||||
$service->handler()->setDefaultCli();
|
||||
$server->defaultService('php')->update(['is_default' => 0]);
|
||||
$service->update(['is_default' => 1]);
|
||||
$service->update(['status' => ServiceStatus::READY]);
|
||||
}
|
||||
|
||||
public function validate(Server $server, array $input): void
|
||||
{
|
||||
if (! isset($input['version']) || ! in_array($input['version'], $server->installedPHPVersions())) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('This version is not installed')]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
33
app/Actions/PHP/GetPHPIni.php
Normal file
33
app/Actions/PHP/GetPHPIni.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\PHP;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class GetPHPIni
|
||||
{
|
||||
public function getIni(Server $server, array $input): string
|
||||
{
|
||||
$this->validate($server, $input);
|
||||
|
||||
$php = $server->php($input['version']);
|
||||
|
||||
try {
|
||||
return $php->handler()->getPHPIni();
|
||||
} catch (\Throwable $e) {
|
||||
throw ValidationException::withMessages(
|
||||
['ini' => $e->getMessage()]
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(Server $server, array $input): void
|
||||
{
|
||||
if (! isset($input['version']) || ! in_array($input['version'], $server->installedPHPVersions())) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('This version is not installed')]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
@ -28,7 +28,14 @@ public function install(Server $server, array $input): void
|
||||
'is_default' => false,
|
||||
]);
|
||||
$php->save();
|
||||
$php->install();
|
||||
|
||||
dispatch(function () use ($php) {
|
||||
$php->handler()->install();
|
||||
$php->status = ServiceStatus::READY;
|
||||
$php->save();
|
||||
})->catch(function () use ($php) {
|
||||
$php->delete();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,12 +48,12 @@ private function validate(Server $server, array $input): void
|
||||
'required',
|
||||
Rule::in(config('core.php_versions')),
|
||||
],
|
||||
])->validateWithBag('installPHP');
|
||||
])->validate();
|
||||
|
||||
if (in_array($input['version'], $server->installedPHPVersions())) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('This version is already installed')]
|
||||
)->errorBag('installPHP');
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,25 +2,35 @@
|
||||
|
||||
namespace App\Actions\PHP;
|
||||
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class InstallPHPExtension
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function handle(Service $service, array $input): Service
|
||||
public function install(Server $server, array $input): Service
|
||||
{
|
||||
$this->validate($server, $input);
|
||||
|
||||
/** @var Service $service */
|
||||
$service = $server->php($input['version']);
|
||||
$typeData = $service->type_data;
|
||||
$typeData['extensions'] = $typeData['extensions'] ?? [];
|
||||
$typeData['extensions'][] = $input['extension'];
|
||||
$service->type_data = $typeData;
|
||||
$service->save();
|
||||
|
||||
$this->validate($service, $input);
|
||||
|
||||
$service->handler()->installExtension($input['name']);
|
||||
dispatch(function () use ($service, $input) {
|
||||
$service->handler()->installExtension($input['extension']);
|
||||
})->catch(function () use ($service, $input) {
|
||||
$service->refresh();
|
||||
$typeData = $service->type_data;
|
||||
$typeData['extensions'] = array_values(array_diff($typeData['extensions'], [$input['extension']]));
|
||||
$service->type_data = $typeData;
|
||||
$service->save();
|
||||
})->onConnection('ssh');
|
||||
|
||||
return $service;
|
||||
}
|
||||
@ -28,18 +38,25 @@ public function handle(Service $service, array $input): Service
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validate(Service $service, array $input): void
|
||||
private function validate(Server $server, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'name' => [
|
||||
'extension' => [
|
||||
'required',
|
||||
'in:'.implode(',', config('core.php_extensions')),
|
||||
],
|
||||
])->validateWithBag('installPHPExtension');
|
||||
'version' => [
|
||||
'required',
|
||||
Rule::in($server->installedPHPVersions()),
|
||||
],
|
||||
])->validate();
|
||||
|
||||
if (in_array($input['name'], $service->type_data['extensions'])) {
|
||||
/** @var Service $service */
|
||||
$service = $server->php($input['version']);
|
||||
|
||||
if (in_array($input['extension'], $service->type_data['extensions'])) {
|
||||
throw ValidationException::withMessages(
|
||||
['name' => __('This extension already installed')]
|
||||
['extension' => __('This extension already installed')]
|
||||
)->errorBag('installPHPExtension');
|
||||
}
|
||||
}
|
||||
|
@ -2,36 +2,48 @@
|
||||
|
||||
namespace App\Actions\PHP;
|
||||
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Models\Server;
|
||||
use App\Models\Service;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UninstallPHP
|
||||
{
|
||||
public function uninstall(Server $server, string $version): void
|
||||
public function uninstall(Server $server, array $input): void
|
||||
{
|
||||
$this->validate($server, $version);
|
||||
$this->validate($server, $input);
|
||||
|
||||
/** @var Service $php */
|
||||
$php = $server->services()->where('type', 'php')->where('version', $version)->first();
|
||||
$php = $server->php($input['version']);
|
||||
$php->status = ServiceStatus::UNINSTALLING;
|
||||
$php->save();
|
||||
|
||||
$php->uninstall();
|
||||
dispatch(function () use ($php) {
|
||||
$php->handler()->uninstall();
|
||||
$php->delete();
|
||||
})->catch(function () use ($php) {
|
||||
$php->status = ServiceStatus::FAILED;
|
||||
$php->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validate(Server $server, string $version): void
|
||||
private function validate(Server $server, array $input): void
|
||||
{
|
||||
$php = $server->services()->where('type', 'php')->where('version', $version)->first();
|
||||
Validator::make($input, [
|
||||
'version' => 'required|string',
|
||||
])->validate();
|
||||
|
||||
if (! $php) {
|
||||
if (! in_array($input['version'], $server->installedPHPVersions())) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('This version has not been installed yet!')]
|
||||
['version' => __('This version is not installed')]
|
||||
);
|
||||
}
|
||||
|
||||
$hasSite = $server->sites()->where('php_version', $version)->first();
|
||||
$hasSite = $server->sites()->where('php_version', $input['version'])->first();
|
||||
if ($hasSite) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('Cannot uninstall this version because some sites are using it!')]
|
||||
|
@ -2,8 +2,9 @@
|
||||
|
||||
namespace App\Actions\PHP;
|
||||
|
||||
use App\Models\Service;
|
||||
use App\Models\Server;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Throwable;
|
||||
@ -13,14 +14,18 @@ class UpdatePHPIni
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function update(Service $service, string $ini): void
|
||||
public function update(Server $server, array $input): void
|
||||
{
|
||||
$this->validate($server, $input);
|
||||
|
||||
$service = $server->php($input['version']);
|
||||
|
||||
$tmpName = Str::random(10).strtotime('now');
|
||||
try {
|
||||
/** @var \Illuminate\Filesystem\FilesystemAdapter $storageDisk */
|
||||
$storageDisk = Storage::disk('local');
|
||||
|
||||
$storageDisk->put($tmpName, $ini);
|
||||
$storageDisk->put($tmpName, $input['ini']);
|
||||
$service->server->ssh('root')->upload(
|
||||
$storageDisk->path($tmpName),
|
||||
"/etc/php/$service->version/cli/php.ini"
|
||||
@ -42,4 +47,21 @@ private function deleteTempFile(string $name): void
|
||||
Storage::disk('local')->delete($name);
|
||||
}
|
||||
}
|
||||
|
||||
public function validate(Server $server, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'ini' => [
|
||||
'required',
|
||||
'string',
|
||||
],
|
||||
'version' => 'required|string',
|
||||
])->validate();
|
||||
|
||||
if (! in_array($input['version'], $server->installedPHPVersions())) {
|
||||
throw ValidationException::withMessages(
|
||||
['version' => __('This version is not installed')]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,8 @@
|
||||
|
||||
class DeleteProject
|
||||
{
|
||||
public function delete(User $user, int $projectId): void
|
||||
public function delete(User $user, Project $project): void
|
||||
{
|
||||
/** @var Project $project */
|
||||
$project = $user->projects()->findOrFail($projectId);
|
||||
|
||||
if ($user->projects()->count() === 1) {
|
||||
throw ValidationException::withMessages([
|
||||
'project' => __('Cannot delete the last project.'),
|
||||
|
@ -26,7 +26,7 @@ private function validate(Project $project, array $input): void
|
||||
'required',
|
||||
'string',
|
||||
'max:255',
|
||||
Rule::unique('projects')->ignore($project->id),
|
||||
Rule::unique('projects')->where('user_id', $project->user_id)->ignore($project->id),
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
|
@ -29,7 +29,23 @@ public function create(mixed $queueable, array $input): void
|
||||
'status' => QueueStatus::CREATING,
|
||||
]);
|
||||
$queue->save();
|
||||
$queue->deploy();
|
||||
|
||||
dispatch(function () use ($queue) {
|
||||
$queue->server->processManager()->handler()->create(
|
||||
$queue->id,
|
||||
$queue->command,
|
||||
$queue->user,
|
||||
$queue->auto_start,
|
||||
$queue->auto_restart,
|
||||
$queue->numprocs,
|
||||
$queue->getLogFile(),
|
||||
$queue->site_id
|
||||
);
|
||||
$queue->status = QueueStatus::RUNNING;
|
||||
$queue->save();
|
||||
})->catch(function () use ($queue) {
|
||||
$queue->delete();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -60,6 +76,6 @@ protected function validate(array $input): void
|
||||
],
|
||||
];
|
||||
|
||||
Validator::make($input, $rules)->validateWithBag('createQueue');
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
}
|
||||
|
14
app/Actions/Queue/DeleteQueue.php
Normal file
14
app/Actions/Queue/DeleteQueue.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Queue;
|
||||
|
||||
use App\Models\Queue;
|
||||
|
||||
class DeleteQueue
|
||||
{
|
||||
public function delete(Queue $queue): void
|
||||
{
|
||||
$queue->server->processManager()->handler()->delete($queue->id, $queue->site_id);
|
||||
$queue->delete();
|
||||
}
|
||||
}
|
13
app/Actions/Queue/GetQueueLogs.php
Normal file
13
app/Actions/Queue/GetQueueLogs.php
Normal file
@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Queue;
|
||||
|
||||
use App\Models\Queue;
|
||||
|
||||
class GetQueueLogs
|
||||
{
|
||||
public function getLogs(Queue $queue): string
|
||||
{
|
||||
return $queue->server->processManager()->handler()->getLogs($queue->getLogFile());
|
||||
}
|
||||
}
|
42
app/Actions/Queue/ManageQueue.php
Normal file
42
app/Actions/Queue/ManageQueue.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Queue;
|
||||
|
||||
use App\Enums\QueueStatus;
|
||||
use App\Models\Queue;
|
||||
|
||||
class ManageQueue
|
||||
{
|
||||
public function start(Queue $queue): void
|
||||
{
|
||||
$queue->status = QueueStatus::STARTING;
|
||||
$queue->save();
|
||||
dispatch(function () use ($queue) {
|
||||
$queue->server->processManager()->handler()->start($queue->id, $queue->site_id);
|
||||
$queue->status = QueueStatus::RUNNING;
|
||||
$queue->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function stop(Queue $queue): void
|
||||
{
|
||||
$queue->status = QueueStatus::STOPPING;
|
||||
$queue->save();
|
||||
dispatch(function () use ($queue) {
|
||||
$queue->server->processManager()->handler()->stop($queue->id, $queue->site_id);
|
||||
$queue->status = QueueStatus::STOPPED;
|
||||
$queue->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function restart(Queue $queue): void
|
||||
{
|
||||
$queue->status = QueueStatus::RESTARTING;
|
||||
$queue->save();
|
||||
dispatch(function () use ($queue) {
|
||||
$queue->server->processManager()->handler()->restart($queue->id, $queue->site_id);
|
||||
$queue->status = QueueStatus::RUNNING;
|
||||
$queue->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
}
|
@ -2,8 +2,10 @@
|
||||
|
||||
namespace App\Actions\SSL;
|
||||
|
||||
use App\Enums\SslStatus;
|
||||
use App\Enums\SslType;
|
||||
use App\Models\Site;
|
||||
use App\Models\Ssl;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
@ -17,13 +19,24 @@ public function create(Site $site, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
if ($input['type'] == SslType::LETSENCRYPT) {
|
||||
$site->createFreeSsl();
|
||||
}
|
||||
$ssl = new Ssl([
|
||||
'site_id' => $site->id,
|
||||
'type' => $input['type'],
|
||||
'certificate' => $input['certificate'] ?? null,
|
||||
'pk' => $input['private'] ?? null,
|
||||
'expires_at' => $input['type'] === SslType::LETSENCRYPT ? now()->addMonths(3) : $input['expires_at'],
|
||||
'status' => SslStatus::CREATING,
|
||||
]);
|
||||
$ssl->save();
|
||||
|
||||
if ($input['type'] == SslType::CUSTOM) {
|
||||
$site->createCustomSsl($input['certificate'], $input['private']);
|
||||
}
|
||||
dispatch(function () use ($site, $ssl) {
|
||||
$site->server->webserver()->handler()->setupSSL($ssl);
|
||||
$ssl->status = SslStatus::CREATED;
|
||||
$ssl->save();
|
||||
$site->type()->edit();
|
||||
})->catch(function () use ($ssl) {
|
||||
$ssl->delete();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@ -34,14 +47,15 @@ protected function validate(array $input): void
|
||||
$rules = [
|
||||
'type' => [
|
||||
'required',
|
||||
Rule::in(SslType::getValues()),
|
||||
Rule::in(config('core.ssl_types')),
|
||||
],
|
||||
];
|
||||
if (isset($input['type']) && $input['type'] == SslType::CUSTOM) {
|
||||
$rules['certificate'] = 'required';
|
||||
$rules['private'] = 'required';
|
||||
$rules['expires_at'] = 'required|date_format:Y-m-d|after_or_equal:'.now();
|
||||
}
|
||||
|
||||
Validator::make($input, $rules)->validateWithBag('createSSL');
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
}
|
||||
|
14
app/Actions/SSL/DeleteSSL.php
Normal file
14
app/Actions/SSL/DeleteSSL.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\SSL;
|
||||
|
||||
use App\Models\Ssl;
|
||||
|
||||
class DeleteSSL
|
||||
{
|
||||
public function delete(Ssl $ssl): void
|
||||
{
|
||||
$ssl->site->server->webserver()->handler()->removeSSL($ssl);
|
||||
$ssl->delete();
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Script;
|
||||
|
||||
use App\Models\Script;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreateScript
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function handle(User $creator, array $input): Script
|
||||
{
|
||||
$this->validateInputs($input);
|
||||
|
||||
$script = new Script([
|
||||
'user_id' => $creator->id,
|
||||
'name' => $input['name'],
|
||||
'content' => $input['content'],
|
||||
]);
|
||||
$script->save();
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validateInputs(array $input): void
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'content' => 'required',
|
||||
];
|
||||
|
||||
Validator::make($input, $rules)->validateWithBag('createScript');
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Script;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Contracts\Pagination\LengthAwarePaginator;
|
||||
|
||||
class GetScripts
|
||||
{
|
||||
public function handle(User $user): LengthAwarePaginator
|
||||
{
|
||||
return $user->scripts()
|
||||
->orderBy('id', 'desc')
|
||||
->paginate(6)
|
||||
->onEachSide(1);
|
||||
}
|
||||
}
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Script;
|
||||
|
||||
use App\Models\Script;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UpdateScript
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function handle(Script $script, array $input): Script
|
||||
{
|
||||
$this->validateInputs($input);
|
||||
|
||||
$script->name = $input['name'];
|
||||
$script->content = $input['content'];
|
||||
$script->save();
|
||||
|
||||
return $script;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validateInputs(array $input): void
|
||||
{
|
||||
$rules = [
|
||||
'name' => 'required',
|
||||
'content' => 'required',
|
||||
];
|
||||
|
||||
Validator::make($input, $rules)->validateWithBag('updateScript');
|
||||
}
|
||||
}
|
30
app/Actions/Server/CheckConnection.php
Normal file
30
app/Actions/Server/CheckConnection.php
Normal file
@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Server;
|
||||
|
||||
use App\Facades\Notifier;
|
||||
use App\Models\Server;
|
||||
use App\Notifications\ServerDisconnected;
|
||||
use Throwable;
|
||||
|
||||
class CheckConnection
|
||||
{
|
||||
public function check(Server $server): Server
|
||||
{
|
||||
$status = $server->status;
|
||||
try {
|
||||
$server->ssh()->connect();
|
||||
$server->refresh();
|
||||
if ($status == 'disconnected') {
|
||||
$server->status = 'ready';
|
||||
$server->save();
|
||||
}
|
||||
} catch (Throwable) {
|
||||
$server->status = 'disconnected';
|
||||
$server->save();
|
||||
Notifier::send($server, new ServerDisconnected($server));
|
||||
}
|
||||
|
||||
return $server;
|
||||
}
|
||||
}
|
@ -3,13 +3,19 @@
|
||||
namespace App\Actions\Server;
|
||||
|
||||
use App\Enums\FirewallRuleStatus;
|
||||
use App\Enums\ServerProvider;
|
||||
use App\Enums\ServerStatus;
|
||||
use App\Exceptions\ServerProviderError;
|
||||
use App\Jobs\Installation\ContinueInstallation;
|
||||
use App\Facades\Notifier;
|
||||
use App\Models\Server;
|
||||
use App\Models\User;
|
||||
use App\Notifications\ServerInstallationFailed;
|
||||
use App\Notifications\ServerInstallationSucceed;
|
||||
use App\ValidationRules\RestrictedIPAddressesRule;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Bus;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Log;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\Rule;
|
||||
@ -30,7 +36,7 @@ public function create(User $creator, array $input): Server
|
||||
'user_id' => $creator->id,
|
||||
'name' => $input['name'],
|
||||
'ssh_user' => config('core.server_providers_default_user')[$input['provider']][$input['os']],
|
||||
'ip' => $input['ip'],
|
||||
'ip' => $input['ip'] ?? '',
|
||||
'port' => $input['port'] ?? 22,
|
||||
'os' => $input['os'],
|
||||
'type' => $input['type'],
|
||||
@ -71,14 +77,8 @@ public function create(User $creator, array $input): Server
|
||||
$server->type()->createServices($input);
|
||||
|
||||
// install server
|
||||
if ($server->provider == 'custom') {
|
||||
$server->install();
|
||||
} else {
|
||||
$server->progress_step = __('Installation will begin in 3 minutes!');
|
||||
$server->save();
|
||||
dispatch(new ContinueInstallation($server))
|
||||
->delay(now()->addMinutes(2));
|
||||
}
|
||||
$this->install($server);
|
||||
|
||||
DB::commit();
|
||||
|
||||
return $server;
|
||||
@ -88,12 +88,44 @@ public function create(User $creator, array $input): Server
|
||||
if ($e instanceof ServerProviderError) {
|
||||
throw ValidationException::withMessages([
|
||||
'provider' => __('Provider Error: ').$e->getMessage(),
|
||||
])->errorBag('createServer');
|
||||
]);
|
||||
}
|
||||
throw $e;
|
||||
}
|
||||
}
|
||||
|
||||
private function install(Server $server): void
|
||||
{
|
||||
$bus = Bus::chain([
|
||||
function () use ($server) {
|
||||
if (! $server->provider()->isRunning()) {
|
||||
sleep(2);
|
||||
}
|
||||
$server->type()->install();
|
||||
$server->update([
|
||||
'status' => ServerStatus::READY,
|
||||
]);
|
||||
Notifier::send($server, new ServerInstallationSucceed($server));
|
||||
},
|
||||
])->catch(function (Throwable $e) use ($server) {
|
||||
$server->update([
|
||||
'status' => ServerStatus::INSTALLATION_FAILED,
|
||||
]);
|
||||
Notifier::send($server, new ServerInstallationFailed($server));
|
||||
Log::error('server-installation-error', [
|
||||
'error' => (string) $e,
|
||||
]);
|
||||
});
|
||||
|
||||
if ($server->provider != ServerProvider::CUSTOM) {
|
||||
$server->progress_step = 'waiting-for-provider';
|
||||
$server->save();
|
||||
$bus->delay(now()->addMinutes(3));
|
||||
}
|
||||
|
||||
$bus->onConnection('ssh')->dispatch();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
@ -136,7 +168,7 @@ private function validateInputs(array $input): void
|
||||
*/
|
||||
private function validateType(Server $server, array $input): void
|
||||
{
|
||||
Validator::make($input, $server->type()->createValidationRules($input))
|
||||
Validator::make($input, $server->type()->createRules($input))
|
||||
->validate();
|
||||
}
|
||||
|
||||
@ -145,7 +177,7 @@ private function validateType(Server $server, array $input): void
|
||||
*/
|
||||
private function validateProvider(Server $server, array $input): void
|
||||
{
|
||||
Validator::make($input, $server->provider()->createValidationRules($input))
|
||||
Validator::make($input, $server->provider()->createRules($input))
|
||||
->validate();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,7 @@ public function edit(Server $server, array $input): Server
|
||||
$server->save();
|
||||
|
||||
if ($checkConnection) {
|
||||
$server->checkConnection();
|
||||
return $server->checkConnection();
|
||||
}
|
||||
|
||||
return $server;
|
||||
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Server;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class GetServers
|
||||
{
|
||||
public function handle(): Collection
|
||||
{
|
||||
return Server::query()->latest()->get();
|
||||
}
|
||||
}
|
23
app/Actions/Server/RebootServer.php
Normal file
23
app/Actions/Server/RebootServer.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Server;
|
||||
|
||||
use App\Enums\ServerStatus;
|
||||
use App\Models\Server;
|
||||
use Throwable;
|
||||
|
||||
class RebootServer
|
||||
{
|
||||
public function reboot(Server $server): Server
|
||||
{
|
||||
try {
|
||||
$server->os()->reboot();
|
||||
$server->status = ServerStatus::DISCONNECTED;
|
||||
$server->save();
|
||||
} catch (Throwable) {
|
||||
$server = $server->checkConnection();
|
||||
}
|
||||
|
||||
return $server;
|
||||
}
|
||||
}
|
@ -2,9 +2,9 @@
|
||||
|
||||
namespace App\Actions\ServerProvider;
|
||||
|
||||
use App\Contracts\ServerProvider as ServerProviderContract;
|
||||
use App\Models\ServerProvider;
|
||||
use App\Models\User;
|
||||
use App\ServerProviders\ServerProvider as ServerProviderContract;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
@ -28,7 +28,7 @@ public function create(User $user, array $input): ServerProvider
|
||||
} catch (Exception) {
|
||||
throw ValidationException::withMessages([
|
||||
'provider' => [
|
||||
__("Couldn't connect to provider. Please check your credentials and try again later."),
|
||||
sprintf("Couldn't connect to %s. Please check your credentials.", $input['provider']),
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
21
app/Actions/ServerProvider/DeleteServerProvider.php
Normal file
21
app/Actions/ServerProvider/DeleteServerProvider.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\ServerProvider;
|
||||
|
||||
use App\Models\ServerProvider;
|
||||
use Exception;
|
||||
|
||||
class DeleteServerProvider
|
||||
{
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete(ServerProvider $serverProvider): void
|
||||
{
|
||||
if ($serverProvider->servers()->exists()) {
|
||||
throw new Exception('This server provider is being used by a server.');
|
||||
}
|
||||
|
||||
$serverProvider->delete();
|
||||
}
|
||||
}
|
@ -1,60 +0,0 @@
|
||||
<?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\ValidationException;
|
||||
|
||||
class InstallPHPMyAdmin
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function install(Server $server, array $input): Service
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
$phpMyAdmin = $server->defaultService('phpmyadmin');
|
||||
if ($phpMyAdmin) {
|
||||
throw ValidationException::withMessages([
|
||||
'allowed_ip' => __('Already installed'),
|
||||
]);
|
||||
}
|
||||
$phpMyAdmin = new Service([
|
||||
'server_id' => $server->id,
|
||||
'type' => 'phpmyadmin',
|
||||
'type_data' => [
|
||||
'allowed_ip' => $input['allowed_ip'],
|
||||
'port' => $input['port'],
|
||||
'php' => $server->defaultService('php')->version,
|
||||
],
|
||||
'name' => 'phpmyadmin',
|
||||
'version' => '5.1.2',
|
||||
'status' => ServiceStatus::INSTALLING,
|
||||
'is_default' => 1,
|
||||
]);
|
||||
$phpMyAdmin->save();
|
||||
$phpMyAdmin->install();
|
||||
|
||||
return $phpMyAdmin;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validate(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'allowed_ip' => 'required',
|
||||
'port' => [
|
||||
'required',
|
||||
'numeric',
|
||||
'min:1',
|
||||
'max:65535',
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
84
app/Actions/Service/Manage.php
Normal file
84
app/Actions/Service/Manage.php
Normal file
@ -0,0 +1,84 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Service;
|
||||
|
||||
use App\Enums\ServiceStatus;
|
||||
use App\Models\Service;
|
||||
|
||||
class Manage
|
||||
{
|
||||
public function start(Service $service): void
|
||||
{
|
||||
$service->status = ServiceStatus::STARTING;
|
||||
$service->save();
|
||||
dispatch(function () use ($service) {
|
||||
$status = $service->server->systemd()->start($service->unit);
|
||||
if (str($status)->contains('Active: active')) {
|
||||
$service->status = ServiceStatus::READY;
|
||||
} else {
|
||||
$service->status = ServiceStatus::FAILED;
|
||||
}
|
||||
$service->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function stop(Service $service): void
|
||||
{
|
||||
$service->status = ServiceStatus::STOPPING;
|
||||
$service->save();
|
||||
dispatch(function () use ($service) {
|
||||
$status = $service->server->systemd()->stop($service->unit);
|
||||
if (str($status)->contains('Active: inactive')) {
|
||||
$service->status = ServiceStatus::STOPPED;
|
||||
} else {
|
||||
$service->status = ServiceStatus::FAILED;
|
||||
}
|
||||
$service->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function restart(Service $service): void
|
||||
{
|
||||
$service->status = ServiceStatus::RESTARTING;
|
||||
$service->save();
|
||||
dispatch(function () use ($service) {
|
||||
$status = $service->server->systemd()->restart($service->unit);
|
||||
if (str($status)->contains('Active: active')) {
|
||||
$service->status = ServiceStatus::READY;
|
||||
} else {
|
||||
$service->status = ServiceStatus::FAILED;
|
||||
}
|
||||
$service->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function enable(Service $service): void
|
||||
{
|
||||
$service->status = ServiceStatus::ENABLING;
|
||||
$service->save();
|
||||
dispatch(function () use ($service) {
|
||||
$status = $service->server->systemd()->enable($service->unit);
|
||||
if (str($status)->contains('Active: active')) {
|
||||
$service->status = ServiceStatus::READY;
|
||||
} else {
|
||||
$service->status = ServiceStatus::FAILED;
|
||||
}
|
||||
$service->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
|
||||
public function disable(Service $service): void
|
||||
{
|
||||
$service->status = ServiceStatus::DISABLING;
|
||||
$service->save();
|
||||
dispatch(function () use ($service) {
|
||||
$status = $service->server->systemd()->disable($service->unit);
|
||||
if (str($status)->contains('Active: inactive')) {
|
||||
$service->status = ServiceStatus::DISABLED;
|
||||
} else {
|
||||
$service->status = ServiceStatus::FAILED;
|
||||
}
|
||||
$service->save();
|
||||
})->onConnection('ssh');
|
||||
}
|
||||
}
|
@ -1,30 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Site;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class ChangePHPVersion
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function handle(Site $site, array $input): void
|
||||
{
|
||||
$this->validate($site, $input);
|
||||
|
||||
$site->changePHPVersion($input['php_version']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function validate(Site $site, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'php_version' => 'required|in:'.implode(',', $site->server->installedPHPVersions()),
|
||||
])->validateWithBag('changePHPVersion');
|
||||
}
|
||||
}
|
@ -1,51 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Redirect;
|
||||
use App\Models\Site;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class CreateRedirect
|
||||
{
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function handle(Site $site, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
$redirect = new Redirect([
|
||||
'site_id' => $site->id,
|
||||
'mode' => $input['mode'],
|
||||
'from' => $input['from'],
|
||||
'to' => $input['to'],
|
||||
]);
|
||||
$redirect->save();
|
||||
$redirect->addToServer();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validate(array $input): void
|
||||
{
|
||||
$rules = [
|
||||
'mode' => [
|
||||
'required',
|
||||
'in:301,302',
|
||||
],
|
||||
'from' => [
|
||||
'required',
|
||||
],
|
||||
'to' => [
|
||||
'required',
|
||||
'url',
|
||||
],
|
||||
];
|
||||
|
||||
Validator::make($input, $rules)->validateWithBag('createRedirect');
|
||||
}
|
||||
}
|
@ -4,8 +4,11 @@
|
||||
|
||||
use App\Enums\SiteStatus;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Facades\Notifier;
|
||||
use App\Models\Server;
|
||||
use App\Models\Site;
|
||||
use App\Notifications\SiteInstallationFailed;
|
||||
use App\Notifications\SiteInstallationSucceed;
|
||||
use App\ValidationRules\DomainRule;
|
||||
use Exception;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@ -30,11 +33,11 @@ public function create(Server $server, array $input): Site
|
||||
'type' => $input['type'],
|
||||
'domain' => $input['domain'],
|
||||
'aliases' => isset($input['alias']) ? [$input['alias']] : [],
|
||||
'path' => '/home/'.$server->ssh_user.'/'.$input['domain'],
|
||||
'path' => '/home/'.$server->getSshUser().'/'.$input['domain'],
|
||||
'status' => SiteStatus::INSTALLING,
|
||||
]);
|
||||
|
||||
// fields based on type
|
||||
// fields based on the type
|
||||
$site->fill($site->type()->createFields($input));
|
||||
|
||||
// check has access to repository
|
||||
@ -63,8 +66,19 @@ public function create(Server $server, array $input): Site
|
||||
'content' => '',
|
||||
]);
|
||||
|
||||
// install server
|
||||
$site->install();
|
||||
// install site
|
||||
dispatch(function () use ($site) {
|
||||
$site->type()->install();
|
||||
$site->update([
|
||||
'status' => SiteStatus::READY,
|
||||
'progress' => 100,
|
||||
]);
|
||||
Notifier::send($site, new SiteInstallationSucceed($site));
|
||||
})->catch(function () use ($site) {
|
||||
$site->status = SiteStatus::INSTALLATION_FAILED;
|
||||
$site->save();
|
||||
Notifier::send($site, new SiteInstallationFailed($site));
|
||||
})->onConnection('ssh');
|
||||
|
||||
DB::commit();
|
||||
|
||||
@ -105,7 +119,7 @@ private function validateInputs(Server $server, array $input): void
|
||||
*/
|
||||
private function validateType(Site $site, array $input): void
|
||||
{
|
||||
$rules = $site->type()->createValidationRules($input);
|
||||
$rules = $site->type()->createRules($input);
|
||||
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
|
14
app/Actions/Site/DeleteSite.php
Normal file
14
app/Actions/Site/DeleteSite.php
Normal file
@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Site;
|
||||
|
||||
class DeleteSite
|
||||
{
|
||||
public function delete(Site $site): void
|
||||
{
|
||||
$site->server->webserver()->handler()->deleteSite($site);
|
||||
$site->delete();
|
||||
}
|
||||
}
|
51
app/Actions/Site/Deploy.php
Normal file
51
app/Actions/Site/Deploy.php
Normal file
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Enums\DeploymentStatus;
|
||||
use App\Exceptions\DeploymentScriptIsEmptyException;
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\Models\Deployment;
|
||||
use App\Models\Site;
|
||||
|
||||
class Deploy
|
||||
{
|
||||
/**
|
||||
* @throws SourceControlIsNotConnected
|
||||
* @throws DeploymentScriptIsEmptyException
|
||||
*/
|
||||
public function run(Site $site): Deployment
|
||||
{
|
||||
if ($site->sourceControl()) {
|
||||
$site->sourceControl()->getRepo($site->repository);
|
||||
}
|
||||
|
||||
if (! $site->deploymentScript?->content) {
|
||||
throw new DeploymentScriptIsEmptyException();
|
||||
}
|
||||
|
||||
$deployment = new Deployment([
|
||||
'site_id' => $site->id,
|
||||
'deployment_script_id' => $site->deploymentScript->id,
|
||||
'status' => DeploymentStatus::DEPLOYING,
|
||||
]);
|
||||
$lastCommit = $site->sourceControl()->provider()->getLastCommit($site->repository, $site->branch);
|
||||
if ($lastCommit) {
|
||||
$deployment->commit_id = $lastCommit['commit_id'];
|
||||
$deployment->commit_data = $lastCommit['commit_data'];
|
||||
}
|
||||
$deployment->save();
|
||||
|
||||
dispatch(function () use ($site, $deployment) {
|
||||
$log = $site->server->os()->runScript($site->path, $site->deploymentScript->content, $site->id);
|
||||
$deployment->status = DeploymentStatus::FINISHED;
|
||||
$deployment->log_id = $log->id;
|
||||
$deployment->save();
|
||||
})->catch(function () use ($deployment) {
|
||||
$deployment->status = DeploymentStatus::FAILED;
|
||||
$deployment->save();
|
||||
})->onConnection('ssh');
|
||||
|
||||
return $deployment;
|
||||
}
|
||||
}
|
@ -1,41 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Site;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class EditSite
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function handle(Site $site, array $input): Site
|
||||
{
|
||||
// validate type
|
||||
$this->validateType($site, $input);
|
||||
|
||||
// set type data
|
||||
$site->type_data = $site->type()->data($input);
|
||||
|
||||
// save
|
||||
$site->port = $input['port'] ?? null;
|
||||
$site->save();
|
||||
|
||||
// edit
|
||||
$site->type()->edit();
|
||||
|
||||
return $site;
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validateType(Site $site, array $input): void
|
||||
{
|
||||
$rules = $site->type()->editValidationRules($input);
|
||||
|
||||
Validator::make($input, $rules)->validateWithBag('editSite');
|
||||
}
|
||||
}
|
@ -1,14 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Server;
|
||||
use Illuminate\Database\Eloquent\Collection;
|
||||
|
||||
class GetSites
|
||||
{
|
||||
public function handle(Server $server): Collection
|
||||
{
|
||||
return $server->sites()->orderBy('id', 'desc')->get();
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Site;
|
||||
use App\SSH\Git\Git;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
@ -14,8 +15,9 @@ class UpdateBranch
|
||||
public function update(Site $site, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
$site->updateBranch($input['branch']);
|
||||
$site->branch = $input['branch'];
|
||||
app(Git::class)->checkout($site);
|
||||
$site->save();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -25,6 +27,6 @@ protected function validate(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'branch' => 'required',
|
||||
])->validateWithBag('updateBranch');
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,6 @@ protected function validate(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'script' => 'required',
|
||||
])->validateWithBag('updateDeploymentScript');
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -8,11 +8,9 @@ class UpdateEnv
|
||||
{
|
||||
public function update(Site $site, array $input): void
|
||||
{
|
||||
$typeData = $site->type_data;
|
||||
$typeData['env'] = $input['env'];
|
||||
$site->type_data = $typeData;
|
||||
$site->save();
|
||||
|
||||
$site->deployEnv();
|
||||
$site->server->os()->editFile(
|
||||
$site->path.'/.env',
|
||||
$input['env']
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -1,35 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\Site;
|
||||
|
||||
use App\Models\Site;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class UpdateSourceControl
|
||||
{
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
public function update(Site $site, array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
$site->source_control_id = $input['source_control'];
|
||||
$site->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
protected function validate(array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'source_control' => [
|
||||
'required',
|
||||
Rule::exists('source_controls', 'id'),
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
@ -13,13 +13,17 @@ class ConnectSourceControl
|
||||
public function connect(array $input): void
|
||||
{
|
||||
$this->validate($input);
|
||||
|
||||
$sourceControl = new SourceControl([
|
||||
'provider' => $input['provider'],
|
||||
'profile' => $input['name'],
|
||||
'access_token' => $input['token'],
|
||||
'url' => Arr::has($input, 'url') ? $input['url'] : null,
|
||||
]);
|
||||
|
||||
$this->validateProvider($sourceControl, $input);
|
||||
|
||||
$sourceControl->provider_data = $sourceControl->provider()->createData($input);
|
||||
|
||||
if (! $sourceControl->provider()->connect()) {
|
||||
throw ValidationException::withMessages([
|
||||
'token' => __('Cannot connect to :provider or invalid token!', ['provider' => $sourceControl->provider]
|
||||
@ -38,20 +42,20 @@ private function validate(array $input): void
|
||||
$rules = [
|
||||
'provider' => [
|
||||
'required',
|
||||
Rule::in(\App\Enums\SourceControl::getValues()),
|
||||
Rule::in(config('core.source_control_providers')),
|
||||
],
|
||||
'name' => [
|
||||
'required',
|
||||
],
|
||||
'token' => [
|
||||
'required',
|
||||
],
|
||||
'url' => [
|
||||
'nullable',
|
||||
'url:http,https',
|
||||
'ends_with:/',
|
||||
],
|
||||
];
|
||||
Validator::make($input, $rules)->validate();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ValidationException
|
||||
*/
|
||||
private function validateProvider(SourceControl $sourceControl, array $input): void
|
||||
{
|
||||
Validator::make($input, $sourceControl->provider()->createRules($input))->validate();
|
||||
}
|
||||
}
|
||||
|
17
app/Actions/SourceControl/DeleteSourceControl.php
Normal file
17
app/Actions/SourceControl/DeleteSourceControl.php
Normal file
@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\SourceControl;
|
||||
|
||||
use App\Models\SourceControl;
|
||||
|
||||
class DeleteSourceControl
|
||||
{
|
||||
public function delete(SourceControl $sourceControl): void
|
||||
{
|
||||
if ($sourceControl->sites()->exists()) {
|
||||
throw new \Exception('This source control is being used by a site.');
|
||||
}
|
||||
|
||||
$sourceControl->delete();
|
||||
}
|
||||
}
|
19
app/Actions/SshKey/DeleteKeyFromServer.php
Normal file
19
app/Actions/SshKey/DeleteKeyFromServer.php
Normal file
@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\SshKey;
|
||||
|
||||
use App\Enums\SshKeyStatus;
|
||||
use App\Models\Server;
|
||||
use App\Models\SshKey;
|
||||
|
||||
class DeleteKeyFromServer
|
||||
{
|
||||
public function delete(Server $server, SshKey $sshKey): void
|
||||
{
|
||||
$sshKey->servers()->updateExistingPivot($server->id, [
|
||||
'status' => SshKeyStatus::DELETING,
|
||||
]);
|
||||
$server->os()->deleteSSHKey($sshKey->public_key);
|
||||
$server->sshKeys()->detach($sshKey);
|
||||
}
|
||||
}
|
38
app/Actions/SshKey/DeployKeyToServer.php
Normal file
38
app/Actions/SshKey/DeployKeyToServer.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\SshKey;
|
||||
|
||||
use App\Enums\SshKeyStatus;
|
||||
use App\Models\Server;
|
||||
use App\Models\SshKey;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Validator;
|
||||
use Illuminate\Validation\Rule;
|
||||
|
||||
class DeployKeyToServer
|
||||
{
|
||||
public function deploy(User $user, Server $server, array $input): void
|
||||
{
|
||||
$this->validate($user, $input);
|
||||
|
||||
/** @var SshKey $sshKey */
|
||||
$sshKey = SshKey::findOrFail($input['key_id']);
|
||||
$server->sshKeys()->attach($sshKey, [
|
||||
'status' => SshKeyStatus::ADDING,
|
||||
]);
|
||||
$server->os()->deploySSHKey($sshKey->public_key);
|
||||
$sshKey->servers()->updateExistingPivot($server->id, [
|
||||
'status' => SshKeyStatus::ADDED,
|
||||
]);
|
||||
}
|
||||
|
||||
private function validate(User $user, array $input): void
|
||||
{
|
||||
Validator::make($input, [
|
||||
'key_id' => [
|
||||
'required',
|
||||
Rule::exists('ssh_keys', 'id')->where('user_id', $user->id),
|
||||
],
|
||||
])->validate();
|
||||
}
|
||||
}
|
@ -27,11 +27,18 @@ public function create(User $user, array $input): void
|
||||
|
||||
$storageProvider->credentials = $storageProvider->provider()->credentialData($input);
|
||||
|
||||
try {
|
||||
if (! $storageProvider->provider()->connect()) {
|
||||
throw ValidationException::withMessages([
|
||||
'provider' => __("Couldn't connect to the provider"),
|
||||
]);
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
throw ValidationException::withMessages([
|
||||
'provider' => $e->getMessage(),
|
||||
]);
|
||||
}
|
||||
|
||||
$storageProvider->save();
|
||||
}
|
||||
|
||||
|
21
app/Actions/StorageProvider/DeleteStorageProvider.php
Normal file
21
app/Actions/StorageProvider/DeleteStorageProvider.php
Normal file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions\StorageProvider;
|
||||
|
||||
use App\Models\StorageProvider;
|
||||
use Exception;
|
||||
|
||||
class DeleteStorageProvider
|
||||
{
|
||||
/**
|
||||
* @throws Exception
|
||||
*/
|
||||
public function delete(StorageProvider $storageProvider): void
|
||||
{
|
||||
if ($storageProvider->backups()->exists()) {
|
||||
throw new Exception('This storage provider is being used by a backup.');
|
||||
}
|
||||
|
||||
$storageProvider->delete();
|
||||
}
|
||||
}
|
74
app/Console/Commands/MigrateFromMysqlToSqlite.php
Normal file
74
app/Console/Commands/MigrateFromMysqlToSqlite.php
Normal file
@ -0,0 +1,74 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class MigrateFromMysqlToSqlite extends Command
|
||||
{
|
||||
protected $signature = 'migrate-from-mysql-to-sqlite';
|
||||
|
||||
protected $description = 'Migrate from Mysql to SQLite';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Migrating from Mysql to SQLite...');
|
||||
|
||||
File::exists(storage_path('database.sqlite'))
|
||||
? File::delete(storage_path('database.sqlite'))
|
||||
: null;
|
||||
|
||||
File::put(storage_path('database.sqlite'), '');
|
||||
|
||||
config(['database.default' => 'sqlite']);
|
||||
|
||||
$this->call('migrate', ['--force' => true]);
|
||||
|
||||
$this->migrateModel(\App\Models\Backup::class);
|
||||
$this->migrateModel(\App\Models\BackupFile::class);
|
||||
$this->migrateModel(\App\Models\CronJob::class);
|
||||
$this->migrateModel(\App\Models\Database::class);
|
||||
$this->migrateModel(\App\Models\DatabaseUser::class);
|
||||
$this->migrateModel(\App\Models\Deployment::class);
|
||||
$this->migrateModel(\App\Models\DeploymentScript::class);
|
||||
$this->migrateModel(\App\Models\FirewallRule::class);
|
||||
$this->migrateModel(\App\Models\GitHook::class);
|
||||
$this->migrateModel(\App\Models\NotificationChannel::class);
|
||||
$this->migrateModel(\App\Models\Project::class);
|
||||
$this->migrateModel(\App\Models\Queue::class);
|
||||
$this->migrateModel(\App\Models\Server::class);
|
||||
$this->migrateModel(\App\Models\ServerLog::class);
|
||||
$this->migrateModel(\App\Models\ServerProvider::class);
|
||||
$this->migrateModel(\App\Models\Service::class);
|
||||
$this->migrateModel(\App\Models\Site::class);
|
||||
$this->migrateModel(\App\Models\SourceControl::class);
|
||||
$this->migrateModel(\App\Models\SshKey::class);
|
||||
$this->migrateModel(\App\Models\Ssl::class);
|
||||
$this->migrateModel(\App\Models\StorageProvider::class);
|
||||
$this->migrateModel(\App\Models\User::class);
|
||||
|
||||
$env = File::get(base_path('.env'));
|
||||
$env = str_replace('DB_CONNECTION=mysql', 'DB_CONNECTION=sqlite', $env);
|
||||
$env = str_replace('DB_DATABASE=vito', '', $env);
|
||||
File::put(base_path('.env'), $env);
|
||||
|
||||
$this->info('Migrated from Mysql to SQLite');
|
||||
}
|
||||
|
||||
private function migrateModel(string $model): void
|
||||
{
|
||||
$this->info("Migrating model: {$model}");
|
||||
|
||||
config(['database.default' => 'mysql']);
|
||||
|
||||
$rows = $model::where('id', '>', 0)->get();
|
||||
|
||||
foreach ($rows as $row) {
|
||||
DB::connection('sqlite')->table($row->getTable())->insert($row->getAttributes());
|
||||
}
|
||||
|
||||
$this->info("Migrated model: {$model}");
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Models\Backup;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RunBackup extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'backups:run {interval}';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Run backup';
|
||||
|
||||
/**
|
||||
* Create a new command instance.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
Backup::query()
|
||||
->where('interval', $this->argument('interval'))
|
||||
->where('status', 'running')
|
||||
->chunk(100, function ($backups) {
|
||||
/** @var Backup $backup */
|
||||
foreach ($backups as $backup) {
|
||||
$backup->run();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
33
app/Console/Commands/RunBackupCommand.php
Normal file
33
app/Console/Commands/RunBackupCommand.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Actions\Database\RunBackup;
|
||||
use App\Enums\BackupStatus;
|
||||
use App\Models\Backup;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class RunBackupCommand extends Command
|
||||
{
|
||||
protected $signature = 'backups:run {interval}';
|
||||
|
||||
protected $description = 'Run backup';
|
||||
|
||||
public function handle(): void
|
||||
{
|
||||
$total = 0;
|
||||
|
||||
Backup::query()
|
||||
->where('interval', $this->argument('interval'))
|
||||
->where('status', BackupStatus::RUNNING)
|
||||
->chunk(100, function ($backups) use (&$total) {
|
||||
/** @var Backup $backup */
|
||||
foreach ($backups as $backup) {
|
||||
app(RunBackup::class)->run($backup);
|
||||
$total++;
|
||||
}
|
||||
});
|
||||
|
||||
$this->info("{$total} backups started");
|
||||
}
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Contracts;
|
||||
|
||||
interface SSHCommand
|
||||
{
|
||||
public function file(): string;
|
||||
|
||||
public function content(): string;
|
||||
}
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class BackupFileStatus extends Enum
|
||||
final class BackupFileStatus
|
||||
{
|
||||
const CREATED = 'created';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class BackupStatus extends Enum
|
||||
final class BackupStatus
|
||||
{
|
||||
const READY = 'ready';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class CronjobStatus extends Enum
|
||||
final class CronjobStatus
|
||||
{
|
||||
const CREATING = 'creating';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class Database extends Enum
|
||||
final class Database
|
||||
{
|
||||
const NONE = 'none';
|
||||
|
||||
@ -13,4 +11,14 @@ final class Database extends Enum
|
||||
const MYSQL80 = 'mysql80';
|
||||
|
||||
const MARIADB = 'mariadb';
|
||||
|
||||
const POSTGRESQL12 = 'postgresql12';
|
||||
|
||||
const POSTGRESQL13 = 'postgresql13';
|
||||
|
||||
const POSTGRESQL14 = 'postgresql14';
|
||||
|
||||
const POSTGRESQL15 = 'postgresql15';
|
||||
|
||||
const POSTGRESQL16 = 'postgresql16';
|
||||
}
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class DatabaseStatus extends Enum
|
||||
final class DatabaseStatus
|
||||
{
|
||||
const READY = 'ready';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class DatabaseUserStatus extends Enum
|
||||
final class DatabaseUserStatus
|
||||
{
|
||||
const READY = 'ready';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class DeploymentStatus extends Enum
|
||||
final class DeploymentStatus
|
||||
{
|
||||
const DEPLOYING = 'deploying';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class FirewallRuleStatus extends Enum
|
||||
final class FirewallRuleStatus
|
||||
{
|
||||
const CREATING = 'creating';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class LogType extends Enum
|
||||
final class LogType
|
||||
{
|
||||
const SERVER = 'server';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class NotificationChannel extends Enum
|
||||
final class NotificationChannel
|
||||
{
|
||||
const EMAIL = 'email';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class OperatingSystem extends Enum
|
||||
final class OperatingSystem
|
||||
{
|
||||
const UBUNTU18 = 'ubuntu_18';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class QueueStatus extends Enum
|
||||
final class QueueStatus
|
||||
{
|
||||
const RUNNING = 'running';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class ServerProvider extends Enum
|
||||
final class ServerProvider
|
||||
{
|
||||
const CUSTOM = 'custom';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class ServerStatus extends Enum
|
||||
final class ServerStatus
|
||||
{
|
||||
const READY = 'ready';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class ServerType extends Enum
|
||||
final class ServerType
|
||||
{
|
||||
const REGULAR = 'regular';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class ServiceStatus extends Enum
|
||||
final class ServiceStatus
|
||||
{
|
||||
const READY = 'ready';
|
||||
|
||||
@ -23,4 +21,10 @@ final class ServiceStatus extends Enum
|
||||
const RESTARTING = 'restarting';
|
||||
|
||||
const STOPPED = 'stopped';
|
||||
|
||||
const ENABLING = 'enabling';
|
||||
|
||||
const DISABLING = 'disabling';
|
||||
|
||||
const DISABLED = 'disabled';
|
||||
}
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class SiteFeature extends Enum
|
||||
final class SiteFeature
|
||||
{
|
||||
const DEPLOYMENT = 'deployment';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class SiteStatus extends Enum
|
||||
final class SiteStatus
|
||||
{
|
||||
const READY = 'ready';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class SiteType extends Enum
|
||||
final class SiteType
|
||||
{
|
||||
const PHP = 'php';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class SourceControl extends Enum
|
||||
final class SourceControl
|
||||
{
|
||||
const GITHUB = 'github';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class SshKeyStatus extends Enum
|
||||
final class SshKeyStatus
|
||||
{
|
||||
const ADDING = 'adding';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class SslStatus extends Enum
|
||||
final class SslStatus
|
||||
{
|
||||
const CREATED = 'created';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class SslType extends Enum
|
||||
final class SslType
|
||||
{
|
||||
const LETSENCRYPT = 'letsencrypt';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class StorageProvider extends Enum
|
||||
final class StorageProvider
|
||||
{
|
||||
const DROPBOX = 'dropbox';
|
||||
|
||||
|
@ -2,9 +2,7 @@
|
||||
|
||||
namespace App\Enums;
|
||||
|
||||
use BenSampo\Enum\Enum;
|
||||
|
||||
final class Webserver extends Enum
|
||||
final class Webserver
|
||||
{
|
||||
const NONE = 'none';
|
||||
|
||||
|
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Events;
|
||||
|
||||
use Illuminate\Broadcasting\InteractsWithSockets;
|
||||
use Illuminate\Foundation\Events\Dispatchable;
|
||||
use Illuminate\Queue\SerializesModels;
|
||||
|
||||
class Broadcast
|
||||
{
|
||||
use Dispatchable, InteractsWithSockets, SerializesModels;
|
||||
|
||||
public function __construct(public string $type, public array $data)
|
||||
{
|
||||
}
|
||||
}
|
@ -1,9 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class BackupFileException extends Exception
|
||||
{
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class CannotDeployKey extends Exception
|
||||
{
|
||||
//
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class ComposerInstallFailed extends Exception
|
||||
{
|
||||
//
|
||||
}
|
9
app/Exceptions/DeploymentScriptIsEmptyException.php
Normal file
9
app/Exceptions/DeploymentScriptIsEmptyException.php
Normal file
@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class DeploymentScriptIsEmptyException extends Exception
|
||||
{
|
||||
}
|
@ -1,10 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exceptions;
|
||||
|
||||
use Exception;
|
||||
|
||||
class FailedToInstallWordpress extends Exception
|
||||
{
|
||||
//
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user