An addin for the Cake Build System to manage services via systemctl service manager.
You can read the latest documentation at cakebuild.net.
Add Cake.Systemctl support to you cake script
#addin Cake.Systemctl
Task("List-Unit-Files")
.Description("List unit files installed on the system")
.Does(() =>
{
Systemctl.ListUnitFiles(
new ListUnitFilesSettings
{
State = "disabled"
}
);
});
Task("List-Units")
.Description("List units that currently was loaded to memory")
.Does(() =>
{
Systemctl.ListUnits(
new ListUnitsSettings
{
All = true,
Type = "service"
}
);
});
Task("Start")
.Description("Start (activate) unit")
.Does(() =>
{
Systemctl.StartUnit(
new UnitSettings { UnitName = "Example" }
);
});
Task("Stop")
.Description("Stop (deactivate) unit")
.Does(() =>
{
Systemctl.StopUnit(
new UnitSettings { UnitName = "Example" }
);
});
Task("Show")
.Description("Show properties of the unit")
.Does(() =>
{
Systemctl.ShowUnit(
new ShowUnitSettings
{
UnitName = "Example",
Properties = new List<string> { "LoadState", "ActiveState" }
}
)
});
Task("Reload-Daemon-OnDemand")
.Description("Reload systemd daemon if it's neccessary")
.Does(() =>
{
var properties = Systemctl.ShowUnit(
new ShowUnitSettings
{
UnitName = "Example",
Properties = new List<string> { "NeedDaemonReload" }
}
);
if (properties.TryGetValue("NeedDaemonReload", out var need)
&& need.Equals("yes", StringComparison.OrdinalIgnoreCase))
{
Systemctl.DaemonReload();
}
});
Copyright © Vadim Hatsura and contributors.
Cake.Systemctl is provided as-is under the MIT license. For more information see LICENSE.