| | 1 | | using Dotnet.Installer.Core.Services.Contracts; |
| | 2 | | using Dotnet.Installer.Core.Types; |
| | 3 | |
|
| | 4 | | namespace Dotnet.Installer.Core.Services.Implementations; |
| | 5 | |
|
| | 6 | | public class SystemdService : ISystemdService |
| | 7 | | { |
| 0 | 8 | | private readonly Terminal.InvocationOptions _globalSystemdOptions = new() |
| 0 | 9 | | { |
| 0 | 10 | | RedirectStandardError = true, |
| 0 | 11 | | RedirectStandardOutput = true, |
| 0 | 12 | | }; |
| | 13 | |
|
| | 14 | | public Task<Terminal.InvocationResult> DaemonReload() |
| 0 | 15 | | { |
| 0 | 16 | | return Terminal.Invoke("systemctl", _globalSystemdOptions, "daemon-reload"); |
| 0 | 17 | | } |
| | 18 | |
|
| | 19 | | public Task<Terminal.InvocationResult> EnableUnit(string unit) |
| 0 | 20 | | { |
| 0 | 21 | | return Terminal.Invoke("systemctl", _globalSystemdOptions, "enable", unit); |
| 0 | 22 | | } |
| | 23 | |
|
| | 24 | | public Task<Terminal.InvocationResult> DisableUnit(string unit) |
| 0 | 25 | | { |
| 0 | 26 | | return Terminal.Invoke("systemctl", _globalSystemdOptions, "disable", unit); |
| 0 | 27 | | } |
| | 28 | |
|
| | 29 | | public Task<Terminal.InvocationResult> StartUnit(string unit) |
| 0 | 30 | | { |
| 0 | 31 | | return Terminal.Invoke("systemctl", _globalSystemdOptions, "start", unit); |
| 0 | 32 | | } |
| | 33 | |
|
| | 34 | | public Task<Terminal.InvocationResult> StopUnit(string unit) |
| 0 | 35 | | { |
| 0 | 36 | | return Terminal.Invoke("systemctl", _globalSystemdOptions, "stop", unit); |
| 0 | 37 | | } |
| | 38 | | } |