13 lines
336 B
Python
13 lines
336 B
Python
import socket
|
|
import subprocess
|
|
|
|
def getHostName():
|
|
return socket.gethostname()
|
|
|
|
def getDomain():
|
|
domainname = subprocess.check_output(['domainname', '-d'], text=True).rstrip()
|
|
return domainname
|
|
|
|
def setFQDN(fqdn):
|
|
result = subprocess.run(['hostnamectl', 'hostname', fqdn], check=True)
|
|
return result.returncode == 0
|