Documentation
¶
Overview ¶
Package install sets Zelie up on a fresh server: its users, its services and how the panel is reached. Every step can run again, so an install that stopped halfway is finished by running it once more.
Index ¶
- Constants
- Variables
- func SFTPSocketUnit() string
- func SFTPUnit() string
- func SetUpSFTP(ctx context.Context, run ExecFunc, root string) (bool, error)
- func TunnelToken(command string) (string, error)
- func Units(opts Options) map[string]string
- type Cloudflared
- type ExecFunc
- type Installer
- type Mode
- type Options
Constants ¶
const ( Binary = "/usr/local/bin/zelie" UnitDir = "/etc/systemd/system" PanelUser = "zelie" ProxyUser = "zelie-proxy" SFTPUser = "zelie-sftp" )
Where an installed Zelie lives.
const ( SFTPService = "zelie-sftp" SFTPSocket = SFTPService + ".socket" )
SFTPService is the SFTP server, and SFTPSocket the socket systemd holds for it. Neither is in Services: the port may be taken by something else on the machine, which must not fail an update.
const DefaultSFTPPort = 2222
DefaultSFTPPort is where the SFTP server listens until the panel says otherwise. It is Pterodactyl's port too.
const DefaultTunnelPort = 8480
DefaultTunnelPort is where the proxy listens behind a tunnel. It clashes with neither the usual web ports nor Pterodactyl's and Pelican's 8080.
Variables ¶
var ErrAdminExists = errors.New("an administrator exists already")
ErrAdminExists is what SetupLink returns on a server set up before.
var Services = []string{"zelie-core", "zelie-proxy", "zelie-panel"}
Services are Zelie's own systemd services, in the order they start. An update waits for each of them to answer.
Functions ¶
func SFTPSocketUnit ¶ added in v0.7.0
func SFTPSocketUnit() string
SFTPSocketUnit is the socket systemd listens on for the SFTP server. The port is the default; the core changes it with a drop-in when the panel says so.
func SFTPUnit ¶ added in v0.7.0
func SFTPUnit() string
SFTPUnit is the unit of the SFTP server. It has no [Install] section: the socket starts it when someone connects, and it exits when idle. It gets its port from the socket, which is above 1023, so it needs no capability at all. It only talks to the panel and the core over their sockets.
func SetUpSFTP ¶ added in v0.7.0
SetUpSFTP gives a server that was installed before SFTP existed the SFTP server: its user, its units, and a place in the firewall. An update restarts the services it knew of, so the new ones have to come from the core, which starts on the new binary. It does nothing on a server that has both already, and reports whether it made anything.
func TunnelToken ¶
TunnelToken takes the token out of the command Cloudflare shows, pasted whole, with or without sudo and the lines before it.
Types ¶
type Cloudflared ¶
type Cloudflared struct {
Arch string
Client *http.Client
Exec func(ctx context.Context, name string, args ...string) (string, error)
}
Cloudflared installs the connector from Cloudflare's package and runs it as a service with the tunnel's token.
type Installer ¶
type Installer struct {
Opts Options
Out io.Writer
// Root is prepended to every path written; empty on a real server.
Root string
// Exec runs a command and returns its combined output.
Exec ExecFunc
// Engine installs containerd and runc.
Engine func(ctx context.Context) error
// Proxy applies the proxy's configuration once it runs.
Proxy func(ctx context.Context, cfg proxy.Config) error
// SetupLink makes the one-time link for the first administrator. It
// returns ErrAdminExists once there is one.
SetupLink func(ctx context.Context) (string, error)
// Cloudflared installs the tunnel's connector; see cloudflared.go.
Cloudflared func(ctx context.Context, token string) error
// Self is the binary running the install.
Self string
// contains filtered or unexported fields
}
Installer does the install. Its fields that touch the machine are replaced in tests.
type Mode ¶
type Mode string
How the panel is reached.
const ( // ModeDomain: the proxy answers on 80 and 443 and gets certificates // from Let's Encrypt. ModeDomain Mode = "domain" // ModeIP: no domain; the proxy serves a self-signed certificate. ModeIP Mode = "ip" // ModeTunnel: a Cloudflare Tunnel brings the traffic; the proxy only // listens on a loopback port. ModeTunnel Mode = "tunnel" )
type Options ¶
type Options struct {
Mode Mode
Host string // the panel's domain, or the server's IP address
Email string // for Let's Encrypt, in domain mode
Port int // loopback port, in tunnel mode
// Cloudflared is the command Cloudflare shows for connecting a new
// tunnel, pasted as it is. Only needed when no connector runs yet.
Cloudflared string
}
Options are the answers the install needs.