initsystem

package
v12.41.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 8, 2022 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package initsystem provides methods for working with different init systems

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsEnabled

func IsEnabled(name string) (bool, error)

IsEnabled returns true if auto start enabled for given service

Example
serviceName := "crond"

enabled, err := IsEnabled(serviceName)

if err != nil {
	fmt.Printf("Error: %v\n", err)
}

if enabled {
	fmt.Printf("Service %s is enabled\n", serviceName)
} else {
	fmt.Printf("Service %s is not enabled\n", serviceName)
}
Output:

func IsPresent

func IsPresent(name string) bool

IsPresent returns true if service is present in any init system

Example
serviceName := "crond"

if IsPresent(serviceName) {
	fmt.Printf("Service %s is present\n", serviceName)
} else {
	fmt.Printf("Unknown service %s\n", serviceName)
}
Output:

func IsWorks

func IsWorks(name string) (bool, error)

IsWorks returns service state

Example
serviceName := "crond"

works, err := IsWorks(serviceName)

if err != nil {
	fmt.Printf("Error: %v\n", err)
}

if works {
	fmt.Printf("Service %s is working\n", serviceName)
} else {
	fmt.Printf("Service %s is stopped\n", serviceName)
}
Output:

func SysV

func SysV() bool

SysV returns true if SysV is used on system

Example
if SysV() {
	fmt.Println("SysV init system is used")
}
Output:

func Systemd

func Systemd() bool

Systemd returns true if Systemd is used on system

Example
if Systemd() {
	fmt.Println("Systemd init system is used")
}
Output:

func Upstart

func Upstart() bool

Upstart returns true if Upstart is used on system

Example
if Upstart() {
	fmt.Println("Upstart init system is used")
}
Output:

Types

This section is empty.

Jump to

Keyboard shortcuts

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