mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Merge pull request #1886 from YunoHost/auto-disable
automatically ignore the service in diagnosis if it has been deactivated with the ynh cli
This commit is contained in:
commit
0783af306d
3 changed files with 15 additions and 7 deletions
|
@ -304,12 +304,12 @@ def _diagnosis_ignore(add_filter=None, remove_filter=None, list=False):
|
||||||
configuration["ignore_filters"][category] = []
|
configuration["ignore_filters"][category] = []
|
||||||
|
|
||||||
if criterias in configuration["ignore_filters"][category]:
|
if criterias in configuration["ignore_filters"][category]:
|
||||||
logger.warning("This filter already exists.")
|
logger.warning(f"(There is already a diagnosis {category} filter with these criterias)")
|
||||||
return
|
return
|
||||||
|
|
||||||
configuration["ignore_filters"][category].append(criterias)
|
configuration["ignore_filters"][category].append(criterias)
|
||||||
_diagnosis_write_configuration(configuration)
|
_diagnosis_write_configuration(configuration)
|
||||||
logger.success("Filter added")
|
logger.success(f"Added a {category} diagnosis filter")
|
||||||
return
|
return
|
||||||
|
|
||||||
if remove_filter:
|
if remove_filter:
|
||||||
|
@ -322,11 +322,12 @@ def _diagnosis_ignore(add_filter=None, remove_filter=None, list=False):
|
||||||
configuration["ignore_filters"][category] = []
|
configuration["ignore_filters"][category] = []
|
||||||
|
|
||||||
if criterias not in configuration["ignore_filters"][category]:
|
if criterias not in configuration["ignore_filters"][category]:
|
||||||
raise YunohostValidationError("This filter does not exists.")
|
logger.warning(f"(There is no such diagnosis {category} filter with these criterias to remove)")
|
||||||
|
return
|
||||||
|
|
||||||
configuration["ignore_filters"][category].remove(criterias)
|
configuration["ignore_filters"][category].remove(criterias)
|
||||||
_diagnosis_write_configuration(configuration)
|
_diagnosis_write_configuration(configuration)
|
||||||
logger.success("Filter removed")
|
logger.success(f"Removed a {category} diagnosis filter")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -26,6 +26,7 @@ from glob import glob
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
from moulinette import m18n
|
from moulinette import m18n
|
||||||
|
from yunohost.diagnosis import diagnosis_ignore, diagnosis_unignore
|
||||||
from yunohost.utils.error import YunohostError, YunohostValidationError
|
from yunohost.utils.error import YunohostError, YunohostValidationError
|
||||||
from moulinette.utils.process import check_output
|
from moulinette.utils.process import check_output
|
||||||
from moulinette.utils.log import getActionLogger
|
from moulinette.utils.log import getActionLogger
|
||||||
|
@ -296,6 +297,9 @@ def service_enable(names):
|
||||||
names = [names]
|
names = [names]
|
||||||
for name in names:
|
for name in names:
|
||||||
if _run_service_command("enable", name):
|
if _run_service_command("enable", name):
|
||||||
|
services = _get_services()
|
||||||
|
if name in services:
|
||||||
|
diagnosis_unignore({"services": [{"service": name}]})
|
||||||
logger.success(m18n.n("service_enabled", service=name))
|
logger.success(m18n.n("service_enabled", service=name))
|
||||||
else:
|
else:
|
||||||
raise YunohostError(
|
raise YunohostError(
|
||||||
|
@ -315,6 +319,9 @@ def service_disable(names):
|
||||||
names = [names]
|
names = [names]
|
||||||
for name in names:
|
for name in names:
|
||||||
if _run_service_command("disable", name):
|
if _run_service_command("disable", name):
|
||||||
|
services = _get_services()
|
||||||
|
if name in services:
|
||||||
|
diagnosis_ignore({"services": [{"service": name}]})
|
||||||
logger.success(m18n.n("service_disabled", service=name))
|
logger.success(m18n.n("service_disabled", service=name))
|
||||||
else:
|
else:
|
||||||
raise YunohostError(
|
raise YunohostError(
|
||||||
|
|
|
@ -41,7 +41,6 @@ from yunohost.app_catalog import (
|
||||||
)
|
)
|
||||||
from yunohost.domain import domain_add
|
from yunohost.domain import domain_add
|
||||||
from yunohost.firewall import firewall_upnp
|
from yunohost.firewall import firewall_upnp
|
||||||
from yunohost.service import service_start, service_enable
|
|
||||||
from yunohost.regenconf import regen_conf
|
from yunohost.regenconf import regen_conf
|
||||||
from yunohost.utils.system import (
|
from yunohost.utils.system import (
|
||||||
_dump_sources_list,
|
_dump_sources_list,
|
||||||
|
@ -156,6 +155,7 @@ def tools_postinstall(
|
||||||
force_diskspace=False,
|
force_diskspace=False,
|
||||||
overwrite_root_password=True,
|
overwrite_root_password=True,
|
||||||
):
|
):
|
||||||
|
from yunohost.service import _run_service_command
|
||||||
from yunohost.dyndns import _dyndns_available, dyndns_unsubscribe
|
from yunohost.dyndns import _dyndns_available, dyndns_unsubscribe
|
||||||
from yunohost.utils.dns import is_yunohost_dyndns_domain
|
from yunohost.utils.dns import is_yunohost_dyndns_domain
|
||||||
from yunohost.utils.password import (
|
from yunohost.utils.password import (
|
||||||
|
@ -270,8 +270,8 @@ def tools_postinstall(
|
||||||
os.system("touch /etc/yunohost/installed")
|
os.system("touch /etc/yunohost/installed")
|
||||||
|
|
||||||
# Enable and start YunoHost firewall at boot time
|
# Enable and start YunoHost firewall at boot time
|
||||||
service_enable("yunohost-firewall")
|
_run_service_command("enable", "yunohost-firewall")
|
||||||
service_start("yunohost-firewall")
|
_run_service_command("start", "yunohost-firewall")
|
||||||
|
|
||||||
regen_conf(names=["ssh"], force=True)
|
regen_conf(names=["ssh"], force=True)
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue