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.
44 lines
1.3 KiB
44 lines
1.3 KiB
<?php
|
|
|
|
namespace init_systems;
|
|
|
|
// Used by: Gentoo, Alpine
|
|
|
|
class open_rc {
|
|
|
|
private static function get_valid_action_for_service(string $action): string|false {
|
|
return match($action) {
|
|
'start'=>'start',
|
|
'stop'=>'stop',
|
|
'status'=>'status',
|
|
'restart'=>'restart',
|
|
'reload'=>'reload',
|
|
default=>false,
|
|
};
|
|
}
|
|
|
|
private static function get_valid_action_for_system_ctl(string $action): string|false {
|
|
return match($action) {
|
|
'show'=>'show',
|
|
'add'=>'add',
|
|
'del'=>'del',
|
|
default=>false,
|
|
};
|
|
}
|
|
|
|
public static function service($name, $action = 'restart') {
|
|
$my_action = self::get_valid_action_for_service($action);
|
|
exec(\neato::get_super_user_bin . 'rc-service ' . safe_cmd($name, $action), $output, $exit_code);
|
|
display($output);
|
|
check_for_error($exit_code, "Unable to {$action} Service called: {$name}");
|
|
return $exit_code;
|
|
}
|
|
|
|
public static function systemctl($name, $action = 'add') {
|
|
$my_action = self::get_valid_action_for_system_ctl($action);
|
|
exec(\neato::get_super_bin . 'rc-update ' . safe_cmd($action, $name), $output, $exit_code);
|
|
check_for_error($exit_code, "Unable to {$action} Service called: {$name}");
|
|
return $exit_code;
|
|
}
|
|
|
|
}
|
|
|