From ee991dbab8c14ca301cbe02dd0fc1c8395511a58 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Sun, 14 Feb 2021 18:35:11 -0800 Subject: [PATCH] action_utils: Introduce utility for masking services Signed-off-by: Sunil Mohan Adapa Reviewed-by: Veiko Aasa --- actions/service | 5 +++++ plinth/action_utils.py | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/actions/service b/actions/service index cb08b0fb8..a9ea57ac9 100755 --- a/actions/service +++ b/actions/service @@ -36,6 +36,7 @@ def parse_arguments(): add_service_action(subparsers, 'reload', 'reload a service') add_service_action(subparsers, 'is-running', 'status of a service') add_service_action(subparsers, 'is-enabled', 'status a service') + add_service_action(subparsers, 'mask', 'unmask a service') add_service_action(subparsers, 'unmask', 'unmask a service') subparsers.add_parser('list', help='List of running system services') @@ -72,6 +73,10 @@ def subcommand_reload(arguments): action_utils.service_reload(arguments.service) +def subcommand_mask(arguments): + action_utils.service_mask(arguments.service) + + def subcommand_unmask(arguments): action_utils.service_unmask(arguments.service) diff --git a/plinth/action_utils.py b/plinth/action_utils.py index 676c3fafb..09a7f3f09 100644 --- a/plinth/action_utils.py +++ b/plinth/action_utils.py @@ -83,6 +83,11 @@ def service_disable(service_name): pass +def service_mask(service_name): + """Mask a service""" + subprocess.call(['systemctl', 'mask', service_name]) + + def service_unmask(service_name): """Unmask a service""" subprocess.call(['systemctl', 'unmask', service_name])