diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-02-13 20:04:33 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-02-13 20:36:05 +0100 |
commit | 05d6085f93df440fe5f8d0d06f63e7be6e9da4b4 (patch) | |
tree | 1e3df7e1bdf5f81befde1cbf98bdfc7b96aea3ae /python/vyos | |
parent | 620cca9750594f1f6a1d8f2f54096b68b1221513 (diff) | |
download | vyos-1x-05d6085f93df440fe5f8d0d06f63e7be6e9da4b4.tar.gz vyos-1x-05d6085f93df440fe5f8d0d06f63e7be6e9da4b4.zip |
vyos.util: T4191: add new sysctl() helper function
(cherry picked from commit b40315b3c5051888f499961e63410e14c5d1bad7)
Diffstat (limited to 'python/vyos')
-rw-r--r-- | python/vyos/util.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/python/vyos/util.py b/python/vyos/util.py index f2f302559..149deabc4 100644 --- a/python/vyos/util.py +++ b/python/vyos/util.py @@ -805,3 +805,12 @@ def boot_configuration_complete() -> bool: if os.path.isfile(config_status): return True return False + +def sysctl(name, value): + """ Change value via sysctl() - return True if changed, False otherwise """ + tmp = cmd(f'sysctl {name}') + # last list index contains the actual value - only write if value differs + if tmp.split()[-1] != str(value): + call(f'sysctl -wq {name}={value}') + return True + return False |