scm

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package scm's Linux implementation replaces the Windows Service Control Manager + registry with systemd (via systemctl) and a root-owned JSON state file. The guard's persistent state - the "disabled" teardown sentinel and the uninstall password hash - lives in that file instead of the registry.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AcquireSingleton

func AcquireSingleton(name string) bool

AcquireSingleton takes an advisory file lock so only one watchdog runs at a time. The file handle is intentionally leaked for the process lifetime; the OS releases the lock on exit.

func ClearPasswordHash

func ClearPasswordHash() error

ClearPasswordHash removes the stored hash (after a verified uninstall).

func EnsureRunning

func EnsureRunning(name string) (string, error)

EnsureRunning enables the service and starts it if it is not already active. It returns "restarted" if it had to start it, otherwise "ok".

func Exists

func Exists(name string) bool

Exists reports whether the systemd unit file is installed.

func GetPasswordHash

func GetPasswordHash() (string, bool)

GetPasswordHash returns the stored hash and whether one is set.

func Harden

func Harden(name string) error

Harden ensures the service starts at boot. Auto-restart on failure is set in the unit at install time (Restart=always, via the guardsvc service options); enabling here covers boot start. Safe to call repeatedly.

func IsDisabled

func IsDisabled() bool

IsDisabled reports whether the disabled sentinel is set.

func IsRunning

func IsRunning(name string) bool

IsRunning reports whether the systemd unit is currently active. It works for an unprivileged caller, so the status UI can use it.

func IsUpdating

func IsUpdating() bool

IsUpdating reports whether an update is currently in progress.

func SetDisabled

func SetDisabled(v bool) error

SetDisabled writes the teardown sentinel; IsDisabled reads it.

func SetPasswordHash

func SetPasswordHash(hash string) error

SetPasswordHash stores the bcrypt hash of the uninstall password.

func SetUpdating

func SetUpdating(v bool) error

SetUpdating writes the sentinel that tells the watchdog to stand down while an update swaps the binaries and restarts the service. IsUpdating reads it.

Types

This section is empty.

Jump to

Keyboard shortcuts

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