diff options
author | hagbard <vyosdev@derith.de> | 2019-03-11 14:59:50 -0700 |
---|---|---|
committer | hagbard <vyosdev@derith.de> | 2019-03-11 14:59:50 -0700 |
commit | df6999ecf8dcae9656a98fe92725a611e400b435 (patch) | |
tree | 3963bcad136c63e3ec9f1b66ee1fa8cbf2478428 /src/conf_mode | |
parent | 49a7c14a815d25dbd46cdbc09dfce2a4dfaeed3e (diff) | |
download | vyos-1x-df6999ecf8dcae9656a98fe92725a611e400b435.tar.gz vyos-1x-df6999ecf8dcae9656a98fe92725a611e400b435.zip |
[rsyslog] Fixes: T1294 - Trying to delete 'system syslog' throws an exception
Diffstat (limited to 'src/conf_mode')
-rwxr-xr-x | src/conf_mode/syslog.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/conf_mode/syslog.py b/src/conf_mode/syslog.py index e726a5755..d600146f3 100755 --- a/src/conf_mode/syslog.py +++ b/src/conf_mode/syslog.py @@ -231,6 +231,9 @@ def generate_selectors(c, config_node): return selectors def generate(c): + if c == None: + return None + tmpl = jinja2.Template(configs, trim_blocks=True) config_text = tmpl.render(c) with open('/etc/rsyslog.d/vyos-rsyslog.conf', 'w') as f: @@ -243,11 +246,12 @@ def generate(c): f.write(config_text) def verify(c): + if c == None: + return None # # /etc/rsyslog.conf is generated somewhere and copied over the original (exists in /opt/vyatta/etc/rsyslog.conf) # it interferes with the global logging, to make sure we are using a single base, template is enforced here # - if not os.path.islink('/etc/rsyslog.conf'): os.remove('/etc/rsyslog.conf') os.symlink('/usr/share/vyos/templates/rsyslog/rsyslog.conf', '/etc/rsyslog.conf') @@ -277,10 +281,16 @@ def verify(c): def apply(c): ### vyatta-log.conf is being generated somewhere ### this is just a quick hack to remove the old configfile - - if os.path.exists('/etc/rsyslog.d/vyatta-log.conf'): - os.remove('/etc/rsyslog.d/vyatta-log.conf') - os.system("sudo systemctl restart rsyslog >/dev/null") + + if c == None: + ### systemd restarts it, using kill + #os.system("sudo systemctl stop rsyslog >/dev/null 2>&1") + print ("systemd sends messages to rsyslog, rsyslog won't be stopped") + else: + if os.path.exists('/etc/rsyslog.d/vyatta-log.conf'): + os.remove('/etc/rsyslog.d/vyatta-log.conf') + + os.system("sudo systemctl restart rsyslog >/dev/null") if __name__ == '__main__': try: |