diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-07-21 20:35:19 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-07-21 20:35:19 +0200 |
commit | ef48b2482f3e516c830c04589193377ee8b45a5e (patch) | |
tree | 8301cdb98a236a948ac53a27ea86b051373835eb /src/conf_mode/service_ids_fastnetmon.py | |
parent | 902586e248dd84883a097a3daca0b1129db25b38 (diff) | |
download | vyos-1x-ef48b2482f3e516c830c04589193377ee8b45a5e.tar.gz vyos-1x-ef48b2482f3e516c830c04589193377ee8b45a5e.zip |
fastnetmon: T2659: move configuration files to /run
Diffstat (limited to 'src/conf_mode/service_ids_fastnetmon.py')
-rwxr-xr-x | src/conf_mode/service_ids_fastnetmon.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/conf_mode/service_ids_fastnetmon.py b/src/conf_mode/service_ids_fastnetmon.py index 8213d536e..615658c84 100755 --- a/src/conf_mode/service_ids_fastnetmon.py +++ b/src/conf_mode/service_ids_fastnetmon.py @@ -27,8 +27,8 @@ from vyos import ConfigError from vyos import airbag airbag.enable() -config_file = r'/etc/fastnetmon.conf' -networks_list = r'/etc/networks_list' +config_file = r'/run/fastnetmon/fastnetmon.conf' +networks_list = r'/run/fastnetmon/networks_list' def get_config(config=None): if config: @@ -36,8 +36,10 @@ def get_config(config=None): else: conf = Config() base = ['service', 'ids', 'ddos-protection'] - fastnetmon = conf.get_config_dict(base, key_mangling=('-', '_'), get_first_key=True) + if not conf.exists(base): + return None + fastnetmon = 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) @@ -65,24 +67,23 @@ def verify(fastnetmon): def generate(fastnetmon): if not fastnetmon: - if os.path.isfile(config_file): - os.unlink(config_file) - if os.path.isfile(networks_list): - os.unlink(networks_list) + for file in [config_file, networks_list]: + if os.path.isfile(file): + os.unlink(file) - return + return None render(config_file, 'ids/fastnetmon.j2', fastnetmon) render(networks_list, 'ids/fastnetmon_networks_list.j2', fastnetmon) - return None def apply(fastnetmon): + systemd_service = 'fastnetmon.service' if not fastnetmon: # Stop fastnetmon service if removed - call('systemctl stop fastnetmon.service') + call(f'systemctl stop {systemd_service}') else: - call('systemctl restart fastnetmon.service') + call(f'systemctl reload-or-restart {systemd_service}') return None |