setup

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2026 License: MIT Imports: 7 Imported by: 0

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

View Source
const (
	BinPath = "/usr/local/bin"
	EtcPath = "/etc/supd"
)

Default install paths, kept aligned with the original install_bin.sh.

View Source
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

func HandlerForTest() map[string]func(op, src, binPath, etcPath string) error

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 PrintUsage

func PrintUsage()

PrintUsage prints the four-line usage banner for `supd setup`.

func Register

func Register(parser *flags.Parser)

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

func RunExtract(src, binPath string) error

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

func SystemdServiceUnit(binPath, etcPath string) string

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

func (c *Command) Execute(args []string) error

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.

Jump to

Keyboard shortcuts

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