systemctl

package module
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 21, 2020 License: MIT Imports: 4 Imported by: 0

README

PkgGoDev

GET

go get -u github.com/g0rbe/go-systemctl

IMPORT

import "github.com/g0rbe/go-systemctl"

Documentation

Overview

Package systemctl provides a wrapper to control systemd services.

example:

nm, err := systemctl.Unit("NetworkManager.service")

if err != nil {
    // Handle error
}

if nm.IsActive() {
	// Handle active service
}

err = nm.Start()
if err != nil {
    // Handle error
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableService added in v1.1.0

func DisableService(name string) error

DisableService function disable the given service in systemd.

func EnableService added in v1.1.0

func EnableService(name string) error

EnableService function enables the given service in systemd.

func IsActive added in v1.1.0

func IsActive(name string) (bool, error)

IsActive checks if the given service is running. Returns true if the the given service is active, returns false otherwise.

func IsEnabled added in v1.1.0

func IsEnabled(name string) (bool, error)

IsEnabled check if the given service is enabled in systemd. Returns true if the the given service is enabled.

func ReloadService added in v1.1.0

func ReloadService(name string) error

ReloadService function reload the given service with systemctl.

func RestartService added in v1.1.0

func RestartService(name string) error

RestartService function restart the given service with systemctl.

func StartService added in v1.1.0

func StartService(name string) error

StartService function start the given service with systemctl.

func StopService added in v1.1.0

func StopService(name string) error

StopService function is stop the given service with systemctl.

Types

type Service

type Service struct {
	Name    string
	Active  bool
	Enabled bool
}

Service provides a struct to store the unit's properties. WILL BE EXPANDED LATER!

func Unit

func Unit(name string) (Service, error)

Unit gives back Service. It checks whether a service with name exist. The struct saves the actual state when the function is called.

func (*Service) Disable

func (s *Service) Disable() error

Disable function disable the given service in systemd.

func (*Service) Enable

func (s *Service) Enable() error

Enable function enables the given service in systemd.

func (*Service) Reload

func (s *Service) Reload() error

Reload function reload the given service with systemctl.

func (*Service) Restart

func (s *Service) Restart() error

Restart function restart the given service with systemctl.

func (*Service) Start

func (s *Service) Start() error

Start function start the given service with systemctl.

func (*Service) Stop

func (s *Service) Stop() error

Stop function is stop the given service with systemctl.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL