deploy

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package deploy installs the awg-agent onto a managed server over SSH. It supports two methods, chosen by the models.AgentSource being deployed:

  • systemd (binary): the agent runs as a systemd unit on the host, driving the AmneziaWG kernel module — see systemd.go. Used for a URL/Path source.
  • docker (image): the agent runs as a Docker container from the source's image (the userspace amneziawg-go build) — see docker.go. Used when the source is an Image.

ToAgent connects and dispatches to the right method; each runs its own pre-deploy check (kernel module for systemd, `docker info` for docker) so a missing prerequisite fails fast with an actionable message.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteCache

func DeleteCache(id uuid.UUID) error

DeleteCache removes id's cached binary, if any. Called when an AgentSource preset with CacheLocally set is deleted, so cache files don't accumulate on disk forever (see Service.DeleteAgentSource).

func RefreshCache

func RefreshCache(ctx context.Context, src models.AgentSource) ([]byte, error)

RefreshCache re-downloads src.URL unconditionally, replacing any previously cached copy — for "rolling" URLs whose content changes over time, where fetchCached's normal "reuse what's already on disk" behavior would otherwise keep deploying whatever was cached the first time forever. Only meaningful for src.CacheLocally == true presets.

func ToAgent

func ToAgent(ctx context.Context, srv models.Server, src models.AgentSource, udpPorts []uint16, passphrase, sudoPassword string, onStep func(string)) error

ToAgent deploys the agent to srv over SSH, dispatching to the systemd or docker method based on src (an Image source → docker, otherwise systemd). udpPorts are the WireGuard ListenPorts of the server's interfaces, published by the docker method so remote clients can reach them (ignored by systemd, which runs on the host network directly). passphrase decrypts srv.SSH's key when it's passphrase-protected (see sshclient.Dial); pass "" when none is cached. sudoPassword is the cached sudo password used when the SSH user isn't root and the host needs one for sudo (see resolveSudo); pass "" to try passwordless sudo first. onStep, if non-nil, is called with a stable step-name key right before each step runs, so a caller can surface deploy progress (e.g. Service.DeployAgent's in-memory status, polled by the frontend) — the names are deliberately untranslated keys, not human-readable text, so the UI can localize them itself. Step keys: "connect", "check_sudo"; systemd: "check_kernel_module", "upload_binary", "upload_unit", "upload_env", "upload_tls", "start_service"; docker: "check_docker", "upload_tls", "start_container".

Types

This section is empty.

Jump to

Keyboard shortcuts

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