sysctl

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultPath   = sysctl.DefaultPath
	TemplatesDir  = "files/sysctl"
	EtcSysctlDir  = "/etc/sysctl.d"
	EtcSysctlConf = "/etc/sysctl.conf"
)

Variables

This section is empty.

Functions

func BackupSettings

func BackupSettings(backupFile string) (string, error)

BackupSettings backs up the current sysctl settings that will be modified by the template configurations If the backup file already exists, it will not be overwritten. It returns the path to the backup file.

func CopyConfiguration

func CopyConfiguration() ([]string, error)

CopyConfiguration copies sysctl configuration files from the embedded templates to the /etc/sysctl.d directory. It overwrites existing files in the destination directory. It returns a list of copied files.

func CurrentCandidateSettings

func CurrentCandidateSettings() (map[string]string, error)

CurrentCandidateSettings returns a map of current sysctl settings that are defined in the template configuration files. It loads the current sysctl settings and the settings from the template files, and filters the current settings to only keep those that are defined in the template files. It returns a map of the filtered settings and an error if any.

func DeleteConfiguration

func DeleteConfiguration() ([]string, error)

DeleteConfiguration removes sysctl configuration files from the /etc/sysctl.d directory that were copied from the templates. It returns a list of removed files.

func DesiredCandidateSettings

func DesiredCandidateSettings() (map[string]string, error)

DesiredCandidateSettings returns a map of desired sysctl settings that are defined in the template configuration files. It loads the settings from the template files and returns them as a map. It returns a map of the desired settings and an error if any.

func FindSysctlConfigFiles

func FindSysctlConfigFiles() ([]string, error)

FindSysctlConfigFiles returns a sorted list of sysctl configuration files in /etc/sysctl.d

func LoadAllConfiguration

func LoadAllConfiguration() ([]string, error)

LoadAllConfiguration reloads sysctl settings from configuration files in /etc/sysctl.d and /etc/sysctl.conf. It returns a list of configuration files that were used to reload sysctl settings. If no configuration files are found, it will still reload sysctl settings from /etc/sysctl.conf if it exists.

func LoadConfigurationFrom

func LoadConfigurationFrom(configFiles []string) ([]string, error)

LoadConfigurationFrom reloads sysctl settings from the given configuration files. If the configFiles slice is empty, it will check for the existence of /etc/sysctl.conf and reload settings from there if it exists. It returns a list of configuration files that were used to reload sysctl settings.

func PathFromKey

func PathFromKey(key string) ([]string, error)

PathFromKey returns the sysctl file path for a given key. It supports patterns with '*' for interface names, e.g. net.ipv4.conf.lxc*.rp_filter Only suffix wildcards are supported. If no wildcard is present, it returns the full path for the given key. If no matching paths are found for a pattern, it returns empty array

func RestoreSettings

func RestoreSettings(backupFile string) error

RestoreSettings restores sysctl settings from the given backup file. It returns an error if the backup file does not exist or if the settings could not be applied.

func Set

func Set(key, value string) error

Set updates the value of a sysctl.

Types

This section is empty.

Jump to

Keyboard shortcuts

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