sservice

package
v1.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const ManPath = "/usr/share/man/man1/"

Variables

View Source
var (
	// ErrUnsupportedSystem appears if try to use service on system which is not supported by this release
	ErrUnsupportedSystem = errors.New("unsupported system")

	// ErrRootPrivileges appears if run installation or deleting the service without root privileges
	ErrRootPrivileges = errors.New("you must have root user privileges. Possibly using 'sudo' command should help")

	// ErrExecNotFound provided executable file does not exists
	ErrExecNotFound = errors.New("executable file does not exists or not provided")

	// ErrServiceNotInstalled provided executable file does not exists
	ErrServiceNotInstalled = errors.New("Service is not installed")
)

Functions

func NewManpageService

func NewManpageService() manpageService

func NewSService

func NewSService(options *Option) *sservice

NewSService ...

Types

type ConfigService

type ConfigService interface {
	WriteConfigAs(filename string) error
	GetString(key string) string
	SetConfigType(in string)
	ReadConfig(in io.Reader) error
}

ConfigService ...

type ManpageService

type ManpageService interface {
	InstallManPages(dir string, serviceName string, cmd *cobra.Command) error
	UninstallManPages(dir string, serviceName string) error
}

type Option

type Option struct {
	ExecPath      string
	ConfigPath    string
	User          string
	Group         string
	UsageExamples string
	UsageDetails  string
	StartUpConfig string
	Config        []byte
}

Option service instance options

func (*Option) WithConfig

func (o *Option) WithConfig(config []byte) *Option

WithConfig sets the startup configurations

func (*Option) WithConfigPath

func (o *Option) WithConfigPath(path string) *Option

WithConfigPath sets the config path

func (*Option) WithExecPath

func (o *Option) WithExecPath(path string) *Option

WithExecPath sets the exec path

func (*Option) WithGroup

func (o *Option) WithGroup(group string) *Option

WithGroup sets the groups

func (*Option) WithStartUpConfig

func (o *Option) WithStartUpConfig(config string) *Option

WithStartUpConfig sets the startup configurations

func (*Option) WithUsageDetails

func (o *Option) WithUsageDetails(usage string) *Option

WithUsageDetails sets usage details

func (*Option) WithUsageExamples

func (o *Option) WithUsageExamples(usage string) *Option

WithUsageExamples sets usage examples

func (*Option) WithUser

func (o *Option) WithUser(user string) *Option

WithUser sets the user

type Sservice

type Sservice interface {
	NewDaemon(serviceName, description string, dependencies ...string) (d daemon.Daemon, err error)
	IsAdmin() (bool, error)
	InstallSetup(serviceName string, cmd *cobra.Command) (err error)
	UninstallSetup(serviceName string) (err error)
	EraseData(serviceName string) (err error)
	IsRunning(status string) bool
	GetDefaultConfigPath(serviceName string) (string, error)

	ReadConfig(serviceName string) (err error)
	InstallConfig(serviceName string) (err error)
	CopyExecInOsDefault(execPath string) (newExecPath string, err error)
	GetDefaultExecPath(serviceName string) (string, error)
	UninstallExecutables(serviceName string) error
}

Sservice ...

type SservicePermissions

type SservicePermissions interface {
	GroupCreateIfNotExists() (err error)
	UserCreateIfNotExists() (err error)
	SetOwnership(path string) (err error)
}

SservicePermissions ...

Jump to

Keyboard shortcuts

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