Merge branch 'sysctl-yaml' into 'main'

Add sysctl option to the "sysconfig" scope of YAML config file

See merge request systemrescue/systemrescue-sources!236
This commit is contained in:
Gerd v. Egidy 2022-10-02 17:06:19 +00:00
commit ae5707d9c3

View file

@ -321,6 +321,23 @@ if 'sysconfig' in config and 'ca-trust' in config['sysconfig'] and config['sysco
with open(firefox_policy_path, "w", encoding='utf-8') as polfile:
json.dump(ff_policy, polfile, ensure_ascii=False, indent=2)
# ==============================================================================
# customize sysctl
# ==============================================================================
if 'sysconfig' in config and 'sysctl' in config['sysconfig'] and \
config['sysconfig']['sysctl'] and isinstance(config['sysconfig']['sysctl'], dict):
print(f"====> Customizing sysctl options ...")
sysctllines = ""
for key, value in config['sysconfig']['sysctl'].items():
sysctllines+=f"{key} = {value}\n"
# pipe config into sysctl
p = subprocess.run(["sysctl", "--load=-"], text=True, input=sysctllines)
if p.returncode is not 0:
print (f"Some or all sysctl options couldn't be set")
errcnt+=1
# ==============================================================================
# late-load a SystemRescueModule (SRM)
# ==============================================================================