add base functionality to YggdrasilService implementors (not tested)
This commit is contained in:
parent
c3ca4e0055
commit
6f7cfb10d0
@ -17,13 +17,26 @@ namespace Yggtk {
|
||||
|
||||
public class YggdrasilServiceOpenRC : Object, YggdrasilService {
|
||||
|
||||
public bool get_status () {
|
||||
return false;
|
||||
public bool get_status () throws SpawnError {
|
||||
string cmd_stdout, cmd_stderr;
|
||||
int cmd_status = -1;
|
||||
|
||||
Process.spawn_command_line_sync ("rc-service yggdrasil status", out cmd_stdout, out cmd_stderr, out cmd_status);
|
||||
|
||||
if (cmd_status != 0 || cmd_stderr.length > 0 || cmd_stdout.contains ("stopped")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public void start () {}
|
||||
public void start () throws SpawnError {
|
||||
Process.spawn_command_line_sync ("pkexec rc-service yggdrasil start");
|
||||
}
|
||||
|
||||
public void stop () {}
|
||||
public void stop () throws SpawnError {
|
||||
Process.spawn_command_line_sync ("pkexec rc-service yggdrasil stop");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,13 +17,26 @@ namespace Yggtk {
|
||||
|
||||
public class YggdrasilServiceSystemd : Object, YggdrasilService {
|
||||
|
||||
public bool get_status () {
|
||||
public bool get_status () throws SpawnError {
|
||||
string cmd_stdout;
|
||||
int cmd_status = -1;
|
||||
|
||||
Process.spawn_command_line_sync ("systemctl status yggdrasil", out cmd_stdout, null, out cmd_status);
|
||||
|
||||
if (cmd_status == 0 && cmd_stdout.contains ("active (running)")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void start () {}
|
||||
public void start () throws SpawnError {
|
||||
Process.spawn_command_line_sync ("pkexec systemctl start yggdrasil");
|
||||
}
|
||||
|
||||
public void stop () {}
|
||||
public void stop () throws SpawnError {
|
||||
Process.spawn_command_line_sync ("pkexec systemctl stop yggdrasil");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -17,9 +17,9 @@ namespace Yggtk {
|
||||
|
||||
public interface YggdrasilService : Object {
|
||||
|
||||
public abstract bool get_status ();
|
||||
public abstract void start ();
|
||||
public abstract void stop ();
|
||||
public abstract bool get_status () throws SpawnError;
|
||||
public abstract void start () throws SpawnError;
|
||||
public abstract void stop () throws SpawnError;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user