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.
 
 

34 lines
949 B

<?php
namespace init_systems;
// Used by: Void, Alpine, and Artix
class runit {
private static function get_valid_action(string $action): string|false {
return match($action) {
'start'=>'start',
'stop'=>'stop',
'status'=>'status',
'force-restart'=>'force-restart',
'enable'=>'enable',
'disable'=>'disable',
'log'=>'log', // View service log
default=>false,
};
}
public static function service(string $name, string $action = 'restart') {
$my_action = self::get_valid_action($action);
exec(\neato::get_super_user_bin . 'sv ' . safe_cmd($my_action, $name), $output, $exit_code);
display($output);
check_for_error($exit_code, "Unable to {$action} Service called: {$name}");
return $exit_code;
}
public static function systemctl(string $name, string $action = 'enable') {
return self::service($name, $action);
}
}