Documentation
¶
Overview ¶
Package setup implements the `supd setup` subcommand, replacing the legacy setup.sh / script/boot_*.sh / script/install_bin.sh stack with a single Go-implemented registry of operations.
The package owns all install/upgrade/clean/extract logic. Per-OS init system handlers (systemd on linux, launchd on darwin) are registered into `handlers` by setup_systemd.go / setup_darwin.go via build tags, so the compiled binary only links the handler matching the target GOOS.
Index ¶
Constants ¶
const ( BinPath = "/usr/local/bin" EtcPath = "/etc/supd" )
Default install paths, kept aligned with the original install_bin.sh.
const DemoIniTpl = `` /* 585-byte string literal not displayed */
DemoIniTpl is a ready-to-use program template written by setup install to <etc-path>/conf.d/demo.ini.tpl. The user renames it to demo.ini (and edits the placeholders) to enable the demo program.
Kept byte-for-byte identical with cmd/supd/etc/supd/conf.d/demo.ini.tpl.
Variables ¶
This section is empty.
Functions ¶
func HandlerForTest ¶
HandlerForTest exposes the handlers map for tests; do not use from production code.
func IsDryRun ¶
func IsDryRun() bool
IsDryRun returns true when the user opts into a non-mutating setup for verification / CI.
func Register ¶
Register wires the setup subcommand into the provided go-flags parser. The supd root package calls this from its init() so that the global `parser` variable does not have to be exported into this package.
func RunExtract ¶
RunExtract implements `supd setup extract --bin-path <dir>`: lay down supd + supc (補齐式) into bin-path only, no etc-path, no init system. Independent of init system — works on plain linux containers / FreeBSD / etc.
func SystemdServiceUnit ¶
SystemdServiceUnit renders /lib/systemd/system/supd.service for the given bin-path + etc-path. Matches the legacy script/supd.service byte-for-byte when the paths match the defaults (/usr/local/bin and /etc/supd).
Types ¶
type Command ¶
type Command struct {
Op string `positional-args:"yes" required:"0" description:"install, upgrade, clean or extract"`
// Flags. Defaults align with the historical install_bin.sh paths.
BinPath string `short:"b" long:"bin-path" description:"destination directory for supd + supc binaries (default /usr/local/bin)"`
EtcPath string `short:"e" long:"etc-path" description:"destination directory for supd.ini and conf.d (default /etc/supd)"`
}
Command is the entry of `supd setup` subcommand. It exposes install/upgrade/clean/extract as four Go-implemented operations.
func (*Command) Execute ¶
Execute implements go-flags.Command; it dispatches on the positional Op field.
func (*Command) ResolveInstallPaths ¶
func (c *Command) ResolveInstallPaths()
ResolveInstallPaths fills in c.BinPath / c.EtcPath with defaults when the user did not provide them on the command line.