mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
[enh] Set main domain as hostname (#219)
This commit is contained in:
parent
035100d6db
commit
1d561123b6
2 changed files with 23 additions and 0 deletions
|
@ -81,6 +81,7 @@
|
||||||
"domain_dyndns_invalid": "Invalid domain to use with DynDNS",
|
"domain_dyndns_invalid": "Invalid domain to use with DynDNS",
|
||||||
"domain_dyndns_root_unknown": "Unknown DynDNS root domain",
|
"domain_dyndns_root_unknown": "Unknown DynDNS root domain",
|
||||||
"domain_exists": "Domain already exists",
|
"domain_exists": "Domain already exists",
|
||||||
|
"domain_hostname_failed": "Failed to set new hostname",
|
||||||
"domain_uninstall_app_first": "One or more apps are installed on this domain. Please uninstall them before proceeding to domain removal",
|
"domain_uninstall_app_first": "One or more apps are installed on this domain. Please uninstall them before proceeding to domain removal",
|
||||||
"domain_unknown": "Unknown domain",
|
"domain_unknown": "Unknown domain",
|
||||||
"domain_zone_exists": "DNS zone file already exists",
|
"domain_zone_exists": "DNS zone file already exists",
|
||||||
|
|
|
@ -163,6 +163,28 @@ def tools_maindomain(auth, new_domain=None):
|
||||||
logger.warning("%s" % e, exc_info=1)
|
logger.warning("%s" % e, exc_info=1)
|
||||||
raise MoulinetteError(errno.EPERM, m18n.n('maindomain_change_failed'))
|
raise MoulinetteError(errno.EPERM, m18n.n('maindomain_change_failed'))
|
||||||
|
|
||||||
|
# Set hostname
|
||||||
|
pretty_hostname = "(YunoHost/%s)" % new_domain
|
||||||
|
commands = [
|
||||||
|
"sudo hostnamectl --static set-hostname".split() + [new_domain],
|
||||||
|
"sudo hostnamectl --transient set-hostname".split() + [new_domain],
|
||||||
|
"sudo hostnamectl --pretty set-hostname".split() + [pretty_hostname]
|
||||||
|
]
|
||||||
|
|
||||||
|
for command in commands:
|
||||||
|
p = subprocess.Popen(command,
|
||||||
|
stdout=subprocess.PIPE,
|
||||||
|
stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
|
out, _ = p.communicate()
|
||||||
|
|
||||||
|
if p.returncode != 0:
|
||||||
|
logger.warning(command)
|
||||||
|
logger.warning(out)
|
||||||
|
raise MoulinetteError(errno.EIO, m18n.n('domain_hostname_failed'))
|
||||||
|
else:
|
||||||
|
logger.info(out)
|
||||||
|
|
||||||
# Regen configurations
|
# Regen configurations
|
||||||
try:
|
try:
|
||||||
with open('/etc/yunohost/installed', 'r') as f:
|
with open('/etc/yunohost/installed', 'r') as f:
|
||||||
|
|
Loading…
Add table
Reference in a new issue