PHP Deployment Scripts
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
neatoDeploy/app/traits/init_systems.php

34 lines
916 B

<?php
namespace traits;
trait init_systems {
private static function getInitSystem(): string|false {
foreach(\neato::$init_systems as $init_dir=>$init_system_name) {
if (file_exists($init_dir) && is_dir($init_dir)) {
return $init_system_name;
}
}
return false;
}
public static function service(string $name, string $action = 'restart') {
$my_init = self::getInitSystem();
if ($my_init === false) {
return false;
}
$namespaced = "\\init_systems\\{$my_init}::service";
return $namespaced($name, $action);
}
public static function systemctl(string $name, string $action = 'enable') {
$my_init = self::getInitSystem();
if ($my_init === false) {
return false;
}
$namespaced = "\\init_systems\\{$my_init}::systemctl";
return $namespaced($name, $action);
}
}