communityscripts

package
v1.4.3 Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GitHubRepo             = "https://github.com/community-scripts/ProxmoxVE"
	GitHubAPIRepo          = "https://api.github.com/repos/community-scripts/ProxmoxVE"
	RawGitHubRepo          = "https://raw.githubusercontent.com/community-scripts/ProxmoxVE/main"
	RawGitHubDevRepo       = "https://raw.githubusercontent.com/community-scripts/ProxmoxVED/main"
	MetadataPocketBaseBase = "https://db.community-scripts.org"
	MetadataPocketBaseAPI  = MetadataPocketBaseBase + "/api/collections"
)

GitHubRepo is the URL to the Proxmox Community Scripts repository.

View Source
const (
	ScriptMetadataTTL = 24 * time.Hour // Cache script metadata for 24 hours
	ScriptListTTL     = 12 * time.Hour // Cache script list for 12 hours
)

Cache TTLs.

View Source
const (
	ScriptMetadataListCacheKey = "communityscripts_script_metadata_list_v3"
	ScriptListCacheKey         = "communityscripts_script_list_v3"
	ScriptCacheKeyPrefix       = "communityscripts_script_"
)

Cache keys.

Variables

This section is empty.

Functions

func AllowedEnvOverrideNames

func AllowedEnvOverrideNames() []string

AllowedEnvOverrideNames returns the supported Community Scripts var_* keys.

func BuildInstallScriptCommand

func BuildInstallScriptCommand(scriptURL string) string

BuildInstallScriptCommand builds the shell command that runs a remote script.

func BuildInstallScriptCommandWithEnv

func BuildInstallScriptCommandWithEnv(scriptURL string, env []EnvOverride) (string, error)

BuildInstallScriptCommandWithEnv builds the shell command that runs a remote script with Community Scripts var_* environment overrides.

func BuildInstallScriptCommandWithEnvAndPreset

func BuildInstallScriptCommandWithEnvAndPreset(scriptURL string, env []EnvOverride, preset string) (string, error)

BuildInstallScriptCommandWithEnvAndPreset builds the shell command that runs a remote script with var_* overrides and an optional Community Scripts preset.

func BuildRemoteInstallCommand

func BuildRemoteInstallCommand(user string, script Script, env []EnvOverride, preset string) (string, error)

BuildRemoteInstallCommand returns the shell command executed on the target node.

func BuildRemoteInstallCommandWithMode added in v1.4.3

func BuildRemoteInstallCommandWithMode(user string, script Script, env []EnvOverride, preset string, nonInteractive bool) (string, error)

BuildRemoteInstallCommandWithMode returns the shell command executed on the target node. In non-interactive mode, sudo uses -n so password prompts fail immediately instead of blocking automation.

func BuildRemoteInstallInLXCCommand added in v1.4.3

func BuildRemoteInstallInLXCCommand(user string, vmid int, script Script, nonInteractive bool) (string, error)

BuildRemoteInstallInLXCCommand returns the shell command executed on a Proxmox node to run a Community Scripts addon inside an existing LXC.

func BuildRemoteInstallInLXCCommandWithEnv added in v1.4.3

func BuildRemoteInstallInLXCCommandWithEnv(user string, vmid int, script Script, env []EnvOverride, preset string, nonInteractive bool) (string, error)

BuildRemoteInstallInLXCCommandWithEnv returns the shell command executed on a Proxmox node to run a Community Scripts addon inside an existing LXC with optional environment overrides.

func InstallScript

func InstallScript(user, nodeIP string, script Script) (int, error)

InstallScript installs a script on a Proxmox node via SSH. Returns the remote exit code (0 on success) and any error encountered.

func InstallScriptInLXC

func InstallScriptInLXC(user, nodeIP string, vmid int, script Script) (int, error)

InstallScriptInLXC installs a script inside an existing LXC container via pct exec.

func InstallScriptInLXCWithOptions added in v1.4.3

func InstallScriptInLXCWithOptions(ctx context.Context, opts InstallOptions, vmid int) (int, error)

InstallScriptInLXCWithOptions installs a script inside an existing LXC container via pct exec.

func InstallScriptWithOptions

func InstallScriptWithOptions(ctx context.Context, opts InstallOptions) (int, error)

InstallScriptWithOptions installs a script on a Proxmox node via SSH.

func IsSensitiveEnvOverride

func IsSensitiveEnvOverride(name string) bool

IsSensitiveEnvOverride reports whether an override value should be redacted in output.

func RawRepoForScript

func RawRepoForScript(script Script) string

RawRepoForScript returns the raw GitHub repository URL for a script.

func RawScriptURL

func RawScriptURL(script Script) string

RawScriptURL returns the direct raw shell script URL.

func ScriptURLExists

func ScriptURLExists(script Script) (bool, error)

ScriptURLExists checks whether the raw install script exists.

func ShellQuote

func ShellQuote(s string) string

ShellQuote wraps a value in single quotes for POSIX shell usage.

func ShellSingleQuote

func ShellSingleQuote(s string) string

ShellSingleQuote escapes a value for inclusion inside a single-quoted shell string.

func ValidateConnection

func ValidateConnection(user, nodeIP string) error

ValidateConnection checks if SSH connection to the node is possible.

func ValidateEnvOverride

func ValidateEnvOverride(override EnvOverride) error

ValidateEnvOverride validates a Community Scripts var_* override.

func ValidateInstallPreset

func ValidateInstallPreset(preset string) error

ValidateInstallPreset validates a Community Scripts menu preset argument.

func WrapRemoteCommandWithBash

func WrapRemoteCommandWithBash(cmd string) string

WrapRemoteCommandWithBash wraps a remote command in /bin/bash -lc.

Types

type EnvOverride

type EnvOverride struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

EnvOverride is a validated Community Scripts environment variable override.

func ParseEnvOverride

func ParseEnvOverride(raw string) (EnvOverride, error)

ParseEnvOverride parses and validates a KEY=VALUE Community Scripts override.

func RedactEnvOverrides

func RedactEnvOverrides(env []EnvOverride) []EnvOverride

RedactEnvOverrides returns a copy with sensitive values replaced.

type GitHubContent

type GitHubContent struct {
	Name        string `json:"name"`
	Path        string `json:"path"`
	Type        string `json:"type"` // "file" or "dir"
	DownloadURL string `json:"download_url"`
}

GitHubContent represents a file or directory in the GitHub API.

func GetScriptMetadataFiles

func GetScriptMetadataFiles() ([]GitHubContent, error)

GetScriptMetadataFiles fetches the list of script metadata JSON files from the repository.

type InstallOptions

type InstallOptions struct {
	User           string
	Host           string
	Keyfile        string
	JumpHost       config.SSHJumpHost
	Script         Script
	Env            []EnvOverride
	Preset         string
	NonInteractive bool
	Stdin          io.Reader
	Stdout         io.Writer
	Stderr         io.Writer
}

InstallOptions describes a community script installation over SSH.

type Script

type Script struct {
	Name          string   `json:"name"`
	Slug          string   `json:"slug"`
	Description   string   `json:"description"`
	Categories    []string `json:"categories"`
	Type          string   `json:"type"` // "ct" for containers, "vm" for VMs
	SourceType    string   `json:"source_type,omitempty"`
	Target        string   `json:"target,omitempty"`
	Updateable    bool     `json:"updateable"`
	Privileged    bool     `json:"privileged"`
	InterfacePort int      `json:"interface_port"`
	Documentation string   `json:"documentation"`
	Website       string   `json:"website"`
	ConfigPath    string   `json:"config_path"`
	ScriptPath    string   // Added for our use, not in the JSON
	DateCreated   string   `json:"date_created"`
	IsDev         bool     `json:"is_dev"`
	IsDisabled    bool     `json:"is_disabled"`
	IsDeleted     bool     `json:"is_deleted"`
}

Script represents a single script from the repository.

func FetchScripts

func FetchScripts() ([]Script, error)

FetchScripts fetches all available scripts from the repository.

func FindScript

func FindScript(scripts []Script, nameOrSlug string) (Script, error)

FindScript finds a script by exact slug or case-insensitive name.

func GetScriptMetadata

func GetScriptMetadata(metadataURL string) (*Script, error)

GetScriptMetadata fetches and parses the metadata for a specific script.

func GetScriptsByCategory

func GetScriptsByCategory(category string) ([]Script, error)

GetScriptsByCategory returns scripts for a specific category.

func NormalizeScript added in v1.4.3

func NormalizeScript(script Script) Script

NormalizeScript fills derived metadata and cleans display text for cached scripts.

func SearchScripts

func SearchScripts(scripts []Script, query string) []Script

SearchScripts returns scripts whose name, slug, or description contains query.

func (Script) SupportsGuestInstall added in v1.4.3

func (s Script) SupportsGuestInstall() bool

SupportsGuestInstall reports whether the script can be run inside an existing LXC.

func (Script) SupportsNodeInstall added in v1.4.3

func (s Script) SupportsNodeInstall() bool

SupportsNodeInstall reports whether the script can be run on a Proxmox node.

type ScriptCategory

type ScriptCategory struct {
	Name        string
	Description string
	Path        string
}

ScriptCategory represents a category of Proxmox scripts.

func GetScriptCategories

func GetScriptCategories() []ScriptCategory

GetScriptCategories returns the available script categories.

Jump to

Keyboard shortcuts

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