docs(README): update installation instructions for various distributions
This commit is contained in:
@@ -3,7 +3,6 @@ package config
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/user"
|
||||
"path/filepath"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
@@ -14,8 +13,8 @@ const DefaultConfigPath = "/etc/unitdore/units.yaml"
|
||||
// Unit represents a single managed container unit.
|
||||
type Unit struct {
|
||||
Name string `yaml:"name"`
|
||||
Runtime string `yaml:"runtime"` // podman | docker | exec
|
||||
User string `yaml:"user,omitempty"` // empty = root/system unit
|
||||
Runtime string `yaml:"runtime"` // podman | docker | exec
|
||||
User string `yaml:"user,omitempty"` // empty = root/system unit
|
||||
Command string `yaml:"command,omitempty"` // override ExecStart
|
||||
Order int `yaml:"order"`
|
||||
Delay string `yaml:"delay,omitempty"` // e.g. "5s"
|
||||
@@ -25,21 +24,9 @@ type Unit struct {
|
||||
|
||||
// Config is the root config structure.
|
||||
type Config struct {
|
||||
Units []Unit `yaml:"units"`
|
||||
Prefix string `yaml:"prefix,omitempty"` // prepended to generated service name, e.g. "prod-"
|
||||
Suffix string `yaml:"suffix,omitempty"` // appended to generated service name, e.g. "-svc"
|
||||
ServiceUser string `yaml:"service_user,omitempty"` // User= in [Service] section; defaults to "unitdore"
|
||||
}
|
||||
|
||||
// EffectiveServiceUser returns the configured service user, or the current OS user if unset.
|
||||
func (c *Config) EffectiveServiceUser() string {
|
||||
if c.ServiceUser != "" {
|
||||
return c.ServiceUser
|
||||
}
|
||||
if u, err := user.Current(); err == nil {
|
||||
return u.Username
|
||||
}
|
||||
return "root"
|
||||
Units []Unit `yaml:"units"`
|
||||
Prefix string `yaml:"prefix,omitempty"` // prepended to generated service name, e.g. "prod-"
|
||||
Suffix string `yaml:"suffix,omitempty"` // appended to generated service name, e.g. "-svc"
|
||||
}
|
||||
|
||||
// Load reads and parses the config file at path.
|
||||
|
||||
Reference in New Issue
Block a user