Documentation
¶
Index ¶
- Constants
- Variables
- func BackupSettings(backupFile string) (string, error)
- func CopyConfiguration() ([]string, error)
- func CopyConfigurationFile(name string) (string, error)
- func CurrentCandidateSettings() (map[string]string, error)
- func DeleteConfiguration() ([]string, error)
- func DesiredCandidateSettings() (map[string]string, error)
- func FindSysctlConfigFiles() ([]string, error)
- func Get(key string) (string, error)
- func LoadAllConfiguration() ([]string, error)
- func LoadConfigurationFrom(configFiles []string) ([]string, error)
- func PathFromKey(key string) ([]string, error)
- func ReadBackupValue(backupFile, key string) (string, bool, error)
- func RestoreSettings(backupFile string) error
- func Set(key, value string) error
Constants ¶
const ( DefaultPath = sysctl.DefaultPath TemplatesDir = "files/sysctl" EtcSysctlDir = "/etc/sysctl.d" EtcSysctlConf = "/etc/sysctl.conf" )
Variables ¶
var ErrKeyNotFound = errorx.InternalError.NewSubtype("sysctl_key_not_found", errorx.NotFound())
ErrKeyNotFound means the kernel has no /proc/sys entry for a sysctl key.
Functions ¶
func BackupSettings ¶
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 ¶
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 CopyConfigurationFile ¶ added in v0.33.0
CopyConfigurationFile copies a single named sysctl configuration file from the embedded templates to the /etc/sysctl.d directory, leaving every other file in the directory untouched. It returns the destination path.
func CurrentCandidateSettings ¶
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 ¶
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 ¶
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 ¶
FindSysctlConfigFiles returns a sorted list of sysctl configuration files in /etc/sysctl.d
func LoadAllConfiguration ¶
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 ¶
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 ¶
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 ReadBackupValue ¶ added in v0.33.0
ReadBackupValue returns the value of key recorded in a sysctl backup file written by BackupSettings. ok is false when the key is not present in the backup, including when the backup file itself does not exist.
func RestoreSettings ¶
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.
Types ¶
This section is empty.