Skip to content

Commit

Permalink
systemctl task updated
Browse files Browse the repository at this point in the history
  • Loading branch information
zoroz committed Dec 18, 2024
1 parent 75e3e57 commit 85e36c9
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/FlubuCore/Tasks/Linux/SystemCtlTask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ public class SystemCtlTask : TaskBase<int, SystemCtlTask>
{
private readonly string _command;
private readonly string _service;
private readonly string _host;

public SystemCtlTask(string command, string service)
/// <summary>
/// Control systemd services.
/// </summary>
/// <param name="command">Command to execute (start, stop, status, ...)</param>
/// <param name="service">Execute command for service unit.</param>
/// <param name="host">Execute command on a remote host.</param>
public SystemCtlTask(string command, string service, string host)
{
_command = command;
_service = service;
_host = host;
}

protected override string Description { get; set; }
Expand All @@ -25,6 +33,9 @@ protected override int DoExecute(ITaskContextInternal context)

if (DoNotFail)
task.DoNotFailOnError();

if (!string.IsNullOrEmpty(_host))
task.WithArguments("-H", _host);

return task.Execute(context);
}
Expand Down

0 comments on commit 85e36c9

Please sign in to comment.