allow to explicit restart service even if not enabled
This commit is contained in:
parent
29c1256ee1
commit
cc206f6198
@ -12,6 +12,9 @@ import sau.platforms
|
|||||||
|
|
||||||
proc_fd_map_re = re.compile(r'^.*(/(?:usr|lib|opt|etc|s?bin)[^\(]*) \(deleted\)$')
|
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):
|
def _warn(policy, msg):
|
||||||
log = logging.getLogger(sau.LOGNAME)
|
log = logging.getLogger(sau.LOGNAME)
|
||||||
if not policy.startswith('silent'):
|
if not policy.startswith('silent'):
|
||||||
@ -182,7 +185,7 @@ def _get_service_restart_policy(service):
|
|||||||
log = logging.getLogger(sau.LOGNAME)
|
log = logging.getLogger(sau.LOGNAME)
|
||||||
conf = sau.config
|
conf = sau.config
|
||||||
policy = conf.get('services', service, fallback=None)
|
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()
|
return policy.lower()
|
||||||
elif policy:
|
elif policy:
|
||||||
log.warning('service policy {} for {} is invalid'.format(policy, service))
|
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')
|
log.warning(f'Not restarting user service {unit}; please log out and log in again')
|
||||||
return None
|
return None
|
||||||
else:
|
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 ])
|
_ret, enabled, _err = sau.helpers.exec_cmd([ '/usr/bin/systemctl', 'is-enabled', unit ])
|
||||||
enabled = enabled.strip()
|
enabled = enabled.strip()
|
||||||
if enabled not in ('enabled', 'static'):
|
if enabled not in ('enabled', 'static'):
|
||||||
|
2
setup.py
2
setup.py
@ -5,7 +5,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='sau',
|
name='sau',
|
||||||
version='1.4.1',
|
version='1.4.2',
|
||||||
description='Tool for auto-updating OS and packages',
|
description='Tool for auto-updating OS and packages',
|
||||||
author='Feffe',
|
author='Feffe',
|
||||||
author_email='feffe@fulh.ax',
|
author_email='feffe@fulh.ax',
|
||||||
|
Loading…
Reference in New Issue
Block a user