summaryrefslogtreecommitdiff
path: root/src/conf_mode/system-options.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/conf_mode/system-options.py')
-rwxr-xr-xsrc/conf_mode/system-options.py30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/conf_mode/system-options.py b/src/conf_mode/system-options.py
index 22765cef7..1061b90ac 100755
--- a/src/conf_mode/system-options.py
+++ b/src/conf_mode/system-options.py
@@ -18,11 +18,14 @@ import os
from netifaces import interfaces
from sys import exit
+from time import sleep
from vyos.config import Config
+from vyos.configdict import dict_merge
from vyos.template import render
from vyos.util import cmd
from vyos.validate import is_addr_assigned
+from vyos.xml import defaults
from vyos import ConfigError
from vyos import airbag
airbag.enable()
@@ -38,6 +41,12 @@ def get_config(config=None):
conf = Config()
base = ['system', 'options']
options = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True)
+
+ # We have gathered the dict representation of the CLI, but there are default
+ # options which we need to update into the dictionary retrived.
+ default_values = defaults(base)
+ options = dict_merge(default_values, options)
+
return options
def verify(options):
@@ -69,8 +78,8 @@ def generate(options):
return None
def apply(options):
- # Beep action
- if 'beep_if_fully_booted' in options.keys():
+ # System bootup beep
+ if 'beep_if_fully_booted' in options:
cmd('systemctl enable vyos-beep.service')
else:
cmd('systemctl disable vyos-beep.service')
@@ -78,34 +87,43 @@ def apply(options):
# Ctrl-Alt-Delete action
if os.path.exists(systemd_action_file):
os.unlink(systemd_action_file)
-
if 'ctrl_alt_del_action' in options:
if options['ctrl_alt_del_action'] == 'reboot':
os.symlink('/lib/systemd/system/reboot.target', systemd_action_file)
elif options['ctrl_alt_del_action'] == 'poweroff':
os.symlink('/lib/systemd/system/poweroff.target', systemd_action_file)
+ # Configure HTTP client
if 'http_client' not in options:
if os.path.exists(curlrc_config):
os.unlink(curlrc_config)
+ # Configure SSH client
if 'ssh_client' not in options:
if os.path.exists(ssh_config):
os.unlink(ssh_config)
# Reboot system on kernel panic
with open('/proc/sys/kernel/panic', 'w') as f:
- if 'reboot_on_panic' in options.keys():
+ if 'reboot_on_panic' in options:
f.write('60')
else:
f.write('0')
# tuned - performance tuning
if 'performance' in options:
- cmd('systemctl enable tuned.service')
+ cmd('systemctl restart tuned.service')
+ # wait until daemon has started before sending configuration
+ while (int(os.system('systemctl is-active --quiet tuned.service')) != 0):
+ sleep(0.250)
cmd('tuned-adm profile network-{performance}'.format(**options))
else:
- cmd('systemctl disable tuned.service')
+ cmd('systemctl stop tuned.service')
+
+ # Keyboard layout - there will be always the default key inside the dict
+ # but we check for key existence anyway
+ if 'keyboard_layout' in options:
+ cmd('loadkeys -C /dev/console {keyboard_layout}'.format(**options))
if __name__ == '__main__':
try: