Skip to content

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

License

Notifications You must be signed in to change notification settings

vhatsura/Cake.Systemctl

Repository files navigation

Cake.Systemctl

NuGet Badge

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

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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages