From df6999ecf8dcae9656a98fe92725a611e400b435 Mon Sep 17 00:00:00 2001 From: hagbard Date: Mon, 11 Mar 2019 14:59:50 -0700 Subject: [rsyslog] Fixes: T1294 - Trying to delete 'system syslog' throws an exception --- src/conf_mode/syslog.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/conf_mode/syslog.py') 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: -- cgit v1.2.3