Skip to main content

Black Friday 2025! Only until December 1st: coupon FRIDAY25 for 40% off Yearly/Lifetime membership!

Read more here

protonemedia/eddy-server-management

507 stars
2 code files
View protonemedia/eddy-server-management on GitHub

app/Server/Software.php

Open in GitHub
use App\Tasks;
use App\Tasks\Task;
use App\Tasks\UpdateAlternatives;
use Illuminate\Support\Str;
 
enum Software: string
{
case Caddy2 = 'caddy2';
case Composer2 = 'composer2';
case MySql80 = 'mysql80';
case Node18 = 'node18';
case Php81 = 'php81';
case Php82 = 'php82';
case Redis6 = 'redis6';
 
/**
* Returns the default stack of software for a fresh server.
*/
public static function defaultStack(): array
{
return [
static::Caddy2,
static::MySql80,
 
// Redis should be installed before PHP
static::Redis6,
static::Php81,
static::Php82,
static::Composer2,
static::Node18,
];
}
 
/**
* Returns the description of the software.
*/
public function getDisplayName(): string
{
return match ($this) {
static::Caddy2 => 'Caddy 2',
static::Composer2 => 'Composer 2',
static::MySql80 => 'MySQL 8.0',
static::Node18 => 'Node 18',
static::Php81 => 'PHP 8.1',
static::Php82 => 'PHP 8.2',
static::Redis6 => 'Redis 6',
};
}
 
/**
* Returns a Task that restarts the software.
*/
public function restartTaskClass(): ?string
{
return match ($this) {
static::Caddy2 => Tasks\ReloadCaddy::class,
static::MySql80 => Tasks\RestartMySql::class,
static::Php81 => Tasks\RestartPhp81::class,
static::Php82 => Tasks\RestartPhp82::class,
static::Redis6 => Tasks\RestartRedis::class,
default => null,
};
}
 
/**
* Returns a Task that makes the software the CLI default.
*/
public function updateAlternativesTask(): ?Task
{
return match ($this) {
static::Php81 => new UpdateAlternatives('php', '/usr/bin/php8.1'),
static::Php82 => new UpdateAlternatives('php', '/usr/bin/php8.2'),
default => null,
};
}
 
/**
* Returns the matching PhpVersion enum for the software.
*/
public function findPhpVersion(): ?PhpVersion
{
return match ($this) {
static::Php81 => PhpVersion::Php81,
static::Php82 => PhpVersion::Php82,
default => null,
};
}
 
/**
* Returns the Blade view name to install the software.
*/
public function getInstallationViewName(): string
{
return 'tasks.software.install-'.Str::replace('_', '-', $this->value);
}
}

app/Http/Controllers/SoftwareController.php

Open in GitHub
use App\Jobs\RestartSoftwareOnServer;
use App\Models\Server;
use App\Server\Software;
use ProtoneMedia\Splade\Facades\Toast;
 
class SoftwareController extends Controller
{
// ...
 
public function restart(Server $server, Software $software)
{
dispatch(new RestartSoftwareOnServer($server, $software));
 
$this->logActivity(__("Restarted ':software' on server ':server'", ['software' => $software->getDisplayName(), 'server' => $server->name]), $server);
 
Toast::success(__(':software will be restarted on the server.', ['software' => $software->getDisplayName()]));
 
return to_route('servers.software.index', $server);
}
}

We'd Love Your Feedback

Tell us what you like or what we can improve

Feel free to share anything you like or dislike about this page or the platform in general.