diff --git a/doc/service/README.md b/doc/service/README.md index a7b8cbed..56564ac4 100644 --- a/doc/service/README.md +++ b/doc/service/README.md @@ -94,3 +94,13 @@ Il est possible de définir une [condition](../condition/README.md) de type "dis ``` Dans ce cas, tous les services et les éléments qu'il compose avec un attribut servicelist à "test" seront désactivés si la variable "condition" est False. + +## Ne pas désactiver le service dans systemd + +La désactivation du service va créé un lien symbolique vers /dev/null. + +Si vous ne voulez juste pas créé le fichier de service et ne pas faire de lien symbolique, il faut utiliser l'attribut undisable : + +``` + +``` diff --git a/src/rougail/data/rougail.dtd b/src/rougail/data/rougail.dtd index 6a8710f0..4bb004dc 100644 --- a/src/rougail/data/rougail.dtd +++ b/src/rougail/data/rougail.dtd @@ -54,6 +54,7 @@ + diff --git a/src/rougail/template/base.py b/src/rougail/template/base.py index ab5873e7..19f12d39 100644 --- a/src/rougail/template/base.py +++ b/src/rougail/template/base.py @@ -343,7 +343,7 @@ class RougailBaseTemplate: service_name = await service_obj.option.description() service_type = await service_obj.information.get('type', 'service') if await service_obj.option('activate').value.get() is False: - if included is False: + if included is False and not await service_obj.information.get('undisable', False): self.desactive_service(service_name, service_type) continue if not included: diff --git a/tests/dictionaries/70service_disabled_undisable/00-base.xml b/tests/dictionaries/70service_disabled_undisable/00-base.xml new file mode 100644 index 00000000..b4f01fc4 --- /dev/null +++ b/tests/dictionaries/70service_disabled_undisable/00-base.xml @@ -0,0 +1,12 @@ + + + + + + + + + no + + + diff --git a/tests/dictionaries/70service_disabled_undisable/__init__.py b/tests/dictionaries/70service_disabled_undisable/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/70service_disabled_undisable/makedict/after.json b/tests/dictionaries/70service_disabled_undisable/makedict/after.json new file mode 100644 index 00000000..08915df9 --- /dev/null +++ b/tests/dictionaries/70service_disabled_undisable/makedict/after.json @@ -0,0 +1,14 @@ +{ + "rougail.condition": { + "owner": "default", + "value": "no" + }, + "services.test.activate": { + "owner": "default", + "value": false + }, + "services.test.manage": { + "owner": "default", + "value": true + } +} diff --git a/tests/dictionaries/70service_disabled_undisable/makedict/base.json b/tests/dictionaries/70service_disabled_undisable/makedict/base.json new file mode 100644 index 00000000..393b57d7 --- /dev/null +++ b/tests/dictionaries/70service_disabled_undisable/makedict/base.json @@ -0,0 +1,5 @@ +{ + "rougail.condition": "no", + "services.test.activate": false, + "services.test.manage": true +} diff --git a/tests/dictionaries/70service_disabled_undisable/makedict/before.json b/tests/dictionaries/70service_disabled_undisable/makedict/before.json new file mode 100644 index 00000000..08915df9 --- /dev/null +++ b/tests/dictionaries/70service_disabled_undisable/makedict/before.json @@ -0,0 +1,14 @@ +{ + "rougail.condition": { + "owner": "default", + "value": "no" + }, + "services.test.activate": { + "owner": "default", + "value": false + }, + "services.test.manage": { + "owner": "default", + "value": true + } +} diff --git a/tests/dictionaries/70service_disabled_undisable/result/tmpfiles.d/0rougail.conf b/tests/dictionaries/70service_disabled_undisable/result/tmpfiles.d/0rougail.conf new file mode 100644 index 00000000..e69de29b diff --git a/tests/dictionaries/70service_disabled_undisable/tiramisu/base.py b/tests/dictionaries/70service_disabled_undisable/tiramisu/base.py new file mode 100644 index 00000000..8c7565e4 --- /dev/null +++ b/tests/dictionaries/70service_disabled_undisable/tiramisu/base.py @@ -0,0 +1,24 @@ +from importlib.machinery import SourceFileLoader as _SourceFileLoader +from importlib.util import spec_from_loader as _spec_from_loader, module_from_spec as _module_from_spec +class func: + pass +_loader = _SourceFileLoader('func', 'tests/dictionaries/../eosfunc/test.py') +_spec = _spec_from_loader(_loader.name, _loader) +_func = _module_from_spec(_spec) +_loader.exec_module(_func) +for function in dir(_func): + if function.startswith('_'): + continue + setattr(func, function, getattr(_func, function)) +try: + from tiramisu3 import * +except: + from tiramisu import * +option_2 = StrOption(name="condition", doc="condition", default="no", properties=frozenset({"mandatory", "normal"})) +option_1 = OptionDescription(name="rougail", doc="rougail", children=[option_2]) +option_5 = BoolOption(name="activate", doc="activate", default=False) +option_6 = BoolOption(name="manage", doc="manage", default=True) +option_4 = OptionDescription(name="test", doc="test", children=[option_5, option_6]) +option_4.impl_set_information('undisable', True) +option_3 = OptionDescription(name="services", doc="services", children=[option_4], properties=frozenset({"hidden"})) +option_0 = OptionDescription(name="baseoption", doc="baseoption", children=[option_1, option_3])