summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhagbard <vyosdev@derith.de>2019-06-17 11:10:33 -0700
committerhagbard <vyosdev@derith.de>2019-06-17 11:10:33 -0700
commit0f354688d7bd63b63fb91faf17a38c77fb05f660 (patch)
treedd690afa6a5cdef7eda5284e93e51aa7503d6958
parent9b4447f039655b9e24187302b9c4d9bb2116aa99 (diff)
downloadvyos-1x-0f354688d7bd63b63fb91faf17a38c77fb05f660.tar.gz
vyos-1x-0f354688d7bd63b63fb91faf17a38c77fb05f660.zip
[syslog/hostname.py] T1394 - syslog systemd and host_name.py race condition
- checking if the hostname has changed, otherwise the script and systemd try to restart rsyslogd at the same time, at the end it's not started at all.
-rwxr-xr-xsrc/conf_mode/host_name.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py
index 621ccd7e0..0d03fd41c 100755
--- a/src/conf_mode/host_name.py
+++ b/src/conf_mode/host_name.py
@@ -248,10 +248,15 @@ def apply(config):
if config['domain_name']:
fqdn += '.' + config['domain_name']
+ # rsyslog runs into a race condition at boot time with systemd
+ # restart rsyslog only if the hostname changed.
+ hn = subprocess.check_output(['hostnamectl','--static']).decode().strip()
+
os.system("hostnamectl set-hostname --static {0}".format(fqdn.rstrip('.')))
# Restart services that use the hostname
- os.system("systemctl restart rsyslog.service")
+ if hn != fqdn:
+ os.system("systemctl restart rsyslog.service")
# If SNMP is running, restart it too
if os.system("pgrep snmpd > /dev/null") == 0: