From cc206f6198e86514fea9fbe2530303693f96c12e Mon Sep 17 00:00:00 2001 From: Fredrik Eriksson Date: Sat, 17 Aug 2024 08:54:43 +0200 Subject: [PATCH] allow to explicit restart service even if not enabled --- sau/services.py | 8 +++++++- setup.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/sau/services.py b/sau/services.py index 03babf1..ca21732 100644 --- a/sau/services.py +++ b/sau/services.py @@ -12,6 +12,9 @@ import sau.platforms proc_fd_map_re = re.compile(r'^.*(/(?:usr|lib|opt|etc|s?bin)[^\(]*) \(deleted\)$') +valid_service_policies=('restart', 'warn', 'ignore', 'silent-restart', + 'reboot', 'silent-reboot') + def _warn(policy, msg): log = logging.getLogger(sau.LOGNAME) if not policy.startswith('silent'): @@ -182,7 +185,7 @@ def _get_service_restart_policy(service): log = logging.getLogger(sau.LOGNAME) conf = sau.config policy = conf.get('services', service, fallback=None) - if policy and policy.lower() in ('restart', 'warn', 'ignore', 'silent-restart', 'reboot', 'silent-reboot'): + if policy and policy.lower() in valid_service_policies: return policy.lower() elif policy: log.warning('service policy {} for {} is invalid'.format(policy, service)) @@ -230,6 +233,9 @@ def _get_service_from_proc(proc): log.warning(f'Not restarting user service {unit}; please log out and log in again') return None else: + policy = conf.get('services', name, fallback=None) + if policy and policy.lower() in valid_service_policies: + return name _ret, enabled, _err = sau.helpers.exec_cmd([ '/usr/bin/systemctl', 'is-enabled', unit ]) enabled = enabled.strip() if enabled not in ('enabled', 'static'): diff --git a/setup.py b/setup.py index db68096..67f9e5d 100755 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ from setuptools import setup, find_packages setup( name='sau', - version='1.4.1', + version='1.4.2', description='Tool for auto-updating OS and packages', author='Feffe', author_email='feffe@fulh.ax',