summaryrefslogtreecommitdiff
path: root/src/conf_mode/host_name.py
diff options
context:
space:
mode:
authorDaniil Baturin <daniil@baturin.org>2019-07-16 23:02:32 +0200
committerDaniil Baturin <daniil@baturin.org>2019-07-16 23:02:32 +0200
commitf62f31fb14aeaff70edb53d0be2d501916e8e39c (patch)
tree3d7e37f2c0b8926b9d3aadf8c3ac9061d7e17ae8 /src/conf_mode/host_name.py
parent016524841da12b68468468cf8f4947b82213ffcd (diff)
downloadvyos-1x-f62f31fb14aeaff70edb53d0be2d501916e8e39c.tar.gz
vyos-1x-f62f31fb14aeaff70edb53d0be2d501916e8e39c.zip
T1531: do not include the domain name in system hostname.
Diffstat (limited to 'src/conf_mode/host_name.py')
-rwxr-xr-xsrc/conf_mode/host_name.py11
1 files 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