mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
c.f. issue #1136, don't fail miserably in case we can't change the hostname because that should be okay
This commit is contained in:
parent
a19df2c09c
commit
fe3ecd7a7d
2 changed files with 7 additions and 14 deletions
|
@ -174,7 +174,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_hostname_failed": "Failed to set new hostname. This might cause issue later (not sure about it... it might be fine).",
|
||||||
"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",
|
||||||
|
|
|
@ -225,10 +225,6 @@ def _set_hostname(hostname, pretty_hostname=None):
|
||||||
Change the machine hostname using hostnamectl
|
Change the machine hostname using hostnamectl
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if _is_inside_container():
|
|
||||||
logger.warning("You are inside a container and hostname cannot easily be changed")
|
|
||||||
return
|
|
||||||
|
|
||||||
if not pretty_hostname:
|
if not pretty_hostname:
|
||||||
pretty_hostname = "(YunoHost/%s)" % hostname
|
pretty_hostname = "(YunoHost/%s)" % hostname
|
||||||
|
|
||||||
|
@ -252,26 +248,23 @@ def _set_hostname(hostname, pretty_hostname=None):
|
||||||
if p.returncode != 0:
|
if p.returncode != 0:
|
||||||
logger.warning(command)
|
logger.warning(command)
|
||||||
logger.warning(out)
|
logger.warning(out)
|
||||||
raise YunohostError('domain_hostname_failed')
|
logger.error(m18n.n('domain_hostname_failed'))
|
||||||
else:
|
else:
|
||||||
logger.debug(out)
|
logger.debug(out)
|
||||||
|
|
||||||
|
|
||||||
def _is_inside_container():
|
def _detect_virt():
|
||||||
"""
|
"""
|
||||||
Check if we're inside a container (i.e. LXC)
|
Returns the output of systemd-detect-virt (so e.g. 'none' or 'lxc' or ...)
|
||||||
|
You can check the man of the command to have a list of possible outputs...
|
||||||
Returns True or False
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# See https://www.2daygeek.com/check-linux-system-physical-virtual-machine-virtualization-technology/
|
p = subprocess.Popen("systemd-detect-virt".split(),
|
||||||
p = subprocess.Popen("sudo systemd-detect-virt".split(),
|
|
||||||
stdout=subprocess.PIPE,
|
stdout=subprocess.PIPE,
|
||||||
stderr=subprocess.STDOUT)
|
stderr=subprocess.STDOUT)
|
||||||
|
|
||||||
out, _ = p.communicate()
|
out, _ = p.communicate()
|
||||||
container = ['lxc', 'lxd', 'docker']
|
return out.split()[0]
|
||||||
return out.split()[0] in container
|
|
||||||
|
|
||||||
|
|
||||||
@is_unit_operation()
|
@is_unit_operation()
|
||||||
|
|
Loading…
Add table
Reference in a new issue