splash

package
v0.8.22 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package splash draws the screen a Jokku server greets you with when you log in: the logo, a striped sun, and live figures about the server and its cluster. It also installs and removes it as the login banner (motd.go).

Index

Constants

This section is empty.

Variables

View Source
var (
	MOTDDir = "/etc/update-motd.d"
	// Dir holds what Disable needs: the state, and a banner script of the
	// admin's own that the splash took the place of.
	Dir = filepath.Join(daemon.DefaultDataDir, "splash")
)

The splash becomes the login banner as a script in /etc/update-motd.d, which pam_motd runs at every SSH login on Debian and Ubuntu. It takes the place of the distribution's own welcome text, which it turns off and remembers turning off, so that Disable can turn it back on. The scripts that warn about something (a restart needed, a new release) keep running.

View Source
var DefaultSources = Sources{
	Proc:    "/proc",
	DataDir: daemon.DefaultDataDir,
	Socket:  client.DefaultSocket,
	Updates: "/var/lib/update-notifier/updates-available",
}

Functions

func AskTerminal

func AskTerminal(question string) (string, bool)

AskTerminal asks on the controlling terminal: install.sh and update.sh run setup with the script itself as stdin. It gives up after two minutes, so an unattended run with a terminal still finishes.

func Decline

func Decline() error

Decline notes that the admin doesn't want the splash, so setup doesn't ask again.

func Disable

func Disable() error

Disable takes the splash off the login banner, puts back what it replaced, and notes not to offer it again.

func Enable

func Enable(exe string) error

Enable makes the splash, drawn by the jokku binary at exe, the login banner. Running it again only brings it up to date.

func Offer

func Offer(out io.Writer, exe string, ask Asker) error

Offer is setup's part. On a server that hasn't decided, it asks whether to show the splash at login (JOKKU_SPLASH=1 or 0 answers in advance); where it's on, it brings the banner script up to date. Without anyone to ask, it says how to turn it on and asks again next time.

func Render

func Render(w io.Writer, in *Info, o Options)

Render draws the splash.

func Supported

func Supported() bool

Supported reports whether this machine runs login banners from /etc/update-motd.d.

func Theirs

func Theirs() bool

Theirs reports whether the splash's place in /etc/update-motd.d is taken by a script jokku didn't write. Enable keeps it in Dir, and Disable puts it back.

Types

type AppHealth

type AppHealth struct {
	Name            string
	Healthy, Wanted int
}

AppHealth is an app with fewer healthy instances than it wants.

type Asker

type Asker func(question string) (answer string, ok bool)

Asker puts a question to whoever runs setup. ok is false when there is no one to ask, or no answer came.

type Info

type Info struct {
	Host    string
	Role    string // control, worker or edge; empty where jokku isn't set up
	Running bool   // the jokku daemon answers
	Status  string // this node's status on the control node: ready, down or draining
	Version string
	Mesh    string // this node's address on the cluster's network

	// Cluster is set when the control node answered; the figures below are
	// the whole cluster's.
	Cluster                          bool
	Apps, Databases, Asleep, Stopped int
	Unhealthy                        []AppHealth
	Nodes, NodesUp, Edges            int
	Down                             []string // nodes that stopped reporting
	Instances                        int
	LastDeploy                       *types.Deploy

	// Here is the instances on this node.
	Here int
	// A worker's or an edge's view of the cluster, from its own files.
	Control string // the control node's address
	Peers   int    // the other nodes it knows of
	Routes  int    // apps an edge routes

	// This machine.
	IP                       string
	CPUs                     int
	Load                     []float64 // over 1, 5 and 15 minutes
	MemoryMB, MemoryUsedMB   int
	DiskMB, DiskUsedMB       int
	DiskAvailMB              int
	Uptime                   time.Duration
	Updates, SecurityUpdates int // packages waiting, from update-notifier

	Now time.Time
}

Info is everything the splash shows. Gather fills it in.

func Gather

func Gather(ctx context.Context, src Sources, timeout time.Duration) *Info

Gather reads this machine, and asks the jokku daemon about the cluster. It gives the daemon at most timeout, so a login is never held up for long; whatever it can't find out is left out.

type Options

type Options struct {
	Color bool
	// Width is the terminal's width in columns, or 0 when it isn't known,
	// as at login; the full splash takes 78.
	Width int
}

Options say what the splash is drawn on.

type Silenced

type Silenced struct {
	Name   string `json:"name"`
	How    string `json:"how"`              // statoverride, chmod or unlink
	Target string `json:"target,omitempty"` // the symlink it removed points here
}

Silenced is a stock welcome script the splash turned off.

type Sources

type Sources struct {
	Proc    string // /proc
	DataDir string // jokku's state, and the filesystem whose disk is shown
	Socket  string // the jokku daemon's API
	Updates string // update-notifier's note of waiting packages
}

Sources are where Gather looks.

type State

type State struct {
	On bool `json:"on"`
	// Declined means the admin said no (or turned it off), so setup
	// doesn't ask again.
	Declined bool       `json:"declined,omitempty"`
	Silenced []Silenced `json:"silenced,omitempty"`
}

State is whether the splash is the login banner here.

func LoadState

func LoadState() (*State, error)

Jump to

Keyboard shortcuts

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