mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Save the value of hostname even if it doesn't appear in /etc/sysconfig/network
https://fedorahosted.org/freeipa/ticket/1871
This commit is contained in:
parent
58918c4593
commit
16fc9f847c
@ -23,6 +23,7 @@ import re
|
||||
import os
|
||||
import stat
|
||||
import sys
|
||||
import socket
|
||||
from ipapython import ipautil
|
||||
from ipapython.platform import base
|
||||
|
||||
@ -133,6 +134,7 @@ def restore_context(filepath):
|
||||
ipautil.run(["/sbin/restorecon", filepath], raiseonerr=False)
|
||||
|
||||
def backup_and_replace_hostname(fstore, statestore, hostname):
|
||||
old_hostname = socket.gethostname()
|
||||
try:
|
||||
ipautil.run(['/bin/hostname', hostname])
|
||||
except ipautil.CalledProcessError, e:
|
||||
@ -144,4 +146,5 @@ def backup_and_replace_hostname(fstore, statestore, hostname):
|
||||
restore_context("/etc/sysconfig/network")
|
||||
if 'HOSTNAME' in old_values:
|
||||
statestore.backup_state('network', 'hostname', old_values['HOSTNAME'])
|
||||
|
||||
else:
|
||||
statestore.backup_state('network', 'hostname', old_hostname)
|
||||
|
Loading…
Reference in New Issue
Block a user