From f62f31fb14aeaff70edb53d0be2d501916e8e39c Mon Sep 17 00:00:00 2001 From: Daniil Baturin Date: Tue, 16 Jul 2019 23:02:32 +0200 Subject: T1531: do not include the domain name in system hostname. --- src/conf_mode/host_name.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/conf_mode/host_name.py b/src/conf_mode/host_name.py index 1988f7b4f..16467c8df 100755 --- a/src/conf_mode/host_name.py +++ b/src/conf_mode/host_name.py @@ -258,18 +258,17 @@ def apply(config): if config is None: return None - fqdn = config['hostname'] - if config['domain_name']: - fqdn += '.' + config['domain_name'] + # No domain name -- the Debian way. + hostname_new = config['hostname'] # 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() + hostname_old = subprocess.check_output(['hostnamectl', '--static']).decode().strip() - os.system("hostnamectl set-hostname --static {0}".format(fqdn.rstrip('.'))) + os.system("hostnamectl set-hostname --static {0}".format(hostname_new)) # Restart services that use the hostname - if hn != fqdn: + if hostname_new != hostname_old: os.system("systemctl restart rsyslog.service") # If SNMP is running, restart it too -- cgit v1.2.3