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 ¶
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 ¶
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 ¶
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:
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.