An addin for the Cake Build System to manage services via systemctl service manager.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Cake.Systemctl
.gitattributes
.gitignore
LICENSE
README.md
azure-pipelines.yml
build.cake
build.ps1
build.sh
cake.systemctl.sln
cake.systemctl.sln.DotSettings

README.md

Cake.Systemctl

NuGet Badge MyGet

An addin for the Cake Build System to manage services via systemctl service manager.

Build Status

Table of Contents

  1. Documentation
  2. Examples
  3. License

Documentation

You can read the latest documentation at cakebuild.net.

Examples

Add Cake.Systemctl support to you cake script

#addin Cake.Systemctl

List unit files

Task("List-Unit-Files")
    .Description("List unit files installed on the system")
    .Does(() =>
    {
        Systemctl.ListUnitFiles(
            new ListUnitFilesSettings
            {
                State = "disabled"
            }
        );
    });

List units

Task("List-Units")
    .Description("List units that currently was loaded to memory")
    .Does(() =>
    {
        Systemctl.ListUnits(
            new ListUnitsSettings
            {
                All = true,
                Type = "service"
            }
        );
    });

Work with unit

Start unit

Task("Start")
    .Description("Start (activate) unit")
    .Does(() =>
    {
        Systemctl.StartUnit(
            new UnitSettings { UnitName = "Example" }
        );
    });

Stop Unit

Task("Stop")
    .Description("Stop (deactivate) unit")
    .Does(() =>
    {
        Systemctl.StopUnit(
            new UnitSettings { UnitName = "Example" }
        );
    });

Show unit properties

Task("Show")
    .Description("Show properties of the unit")
    .Does(() =>
    {
        Systemctl.ShowUnit(
            new ShowUnitSettings
            {
                UnitName = "Example",
                Properties = new List<string> { "LoadState", "ActiveState" }
            }
        )
    });

Daemon reload

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();
        }
    });

License

Copyright © Vadim Hatsura and contributors.

Cake.Systemctl is provided as-is under the MIT license. For more information see LICENSE.