updater

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: AGPL-3.0 Imports: 15 Imported by: 0

Documentation

Overview

Package updater self-updates the panel binary from its GitHub Releases: it finds the latest release, downloads the matching asset, verifies its SHA-256 against the release's SHA256SUMS BEFORE the binary is ever executed or swapped in, then atomically replaces the running executable (keeping a .bak for rollback). The caller restarts the service so systemd re-execs the new binary (and respawns the supervised Xray).

Index

Constants

View Source
const Repo = "AppsGanin/rospanel"

Repo is the GitHub "owner/repo" this panel self-updates from, baked into the build. Change it here if the project moves.

Variables

View Source
var AssetName = fmt.Sprintf("rospanel-%s-%s", runtime.GOOS, runtime.GOARCH)

AssetName is the release asset this build updates from, e.g. "rospanel-linux-amd64".

Functions

func Apply

func Apply(ctx context.Context, rel *Release, backupFn func() error) error

Apply downloads the release asset, VERIFIES its SHA-256 against the release's SHA256SUMS before the binary is ever executed, smoke-tests it, runs backupFn as a pre-update snapshot (best-effort), then atomically replaces the running executable — keeping the previous binary as <exe>.bak for rollback. It does NOT restart the service — the caller does that. Refuses to update a release that ships no SHA256SUMS (integrity cannot be proven).

func IsNewer

func IsNewer(latest, current string) bool

IsNewer reports whether semver `latest` is strictly newer than `current` (numeric, dot-separated; non-numeric or shorter parts compare conservatively).

func Restart

func Restart()

Restart asks systemd to restart the rospanel service in a DECOUPLED transient unit, so the restart (which kills this very process and its child Xray) can't abort itself. A short delay lets the triggering HTTP response flush first.

Types

type Release

type Release struct {
	Version     string `json:"version"` // semver without a leading "v"
	Notes       string `json:"notes"`   // release body (changelog)
	AssetURL    string `json:"-"`       // download URL of AssetName
	ChecksumURL string `json:"-"`       // download URL of the SHA256SUMS asset
}

Release is the newest published release of the configured repo.

func Latest

func Latest(ctx context.Context, repo string) (*Release, error)

Latest queries the GitHub Releases API for the newest release of "owner/repo".

Jump to

Keyboard shortcuts

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