summaryrefslogtreecommitdiff
path: root/src/conf_mode/host_name.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-06-17 20:13:13 +0200
committerDaniil Baturin <daniil@baturin.org>2019-06-17 20:13:13 +0200
commit8b66a1775fc9cf508195ec5c49c9e3516f37a23a (patch)
treeb1f213f7871c684af572c5338d23cd5b315463c1 /src/conf_mode/host_name.py
parent7f06879361999e3b3aab6f66bb267841d958bfdb (diff)
parent0f354688d7bd63b63fb91faf17a38c77fb05f660 (diff)
downloadvyos-1x-8b66a1775fc9cf508195ec5c49c9e3516f37a23a.tar.gz
vyos-1x-8b66a1775fc9cf508195ec5c49c9e3516f37a23a.zip
Merge branch 'current' of https://github.com/vyos/vyos-1x into current
Diffstat (limited to 'src/conf_mode/host_name.py')
-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: