mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
action_utils: Drop support for non-systemd environments
- There hasn't been a need for this for a long time. non-systemd environments haven't been worked on or tested for in a long time. - Keep the is_systemd_running() method for future use. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
e3a67da8ec
commit
6a0493a752
@ -39,13 +39,8 @@ def service_is_running(servicename):
|
|||||||
Does not need to run as root.
|
Does not need to run as root.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
if is_systemd_running():
|
subprocess.run(['systemctl', 'status', servicename], check=True,
|
||||||
subprocess.run(['systemctl', 'status', servicename], check=True,
|
stdout=subprocess.DEVNULL)
|
||||||
stdout=subprocess.DEVNULL)
|
|
||||||
else:
|
|
||||||
subprocess.run(['service', servicename, 'status'], check=True,
|
|
||||||
stdout=subprocess.DEVNULL)
|
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except subprocess.CalledProcessError:
|
except subprocess.CalledProcessError:
|
||||||
# If a service is not running we get a status code != 0 and
|
# If a service is not running we get a status code != 0 and
|
||||||
@ -126,12 +121,8 @@ def service_reload(service_name):
|
|||||||
|
|
||||||
def service_action(service_name, action):
|
def service_action(service_name, action):
|
||||||
"""Perform the given action on the service_name."""
|
"""Perform the given action on the service_name."""
|
||||||
if is_systemd_running():
|
subprocess.run(['systemctl', action, service_name],
|
||||||
subprocess.run(['systemctl', action, service_name],
|
stdout=subprocess.DEVNULL, check=False)
|
||||||
stdout=subprocess.DEVNULL, check=False)
|
|
||||||
else:
|
|
||||||
subprocess.run(['service', service_name, action],
|
|
||||||
stdout=subprocess.DEVNULL, check=False)
|
|
||||||
|
|
||||||
|
|
||||||
def webserver_is_enabled(name, kind='config'):
|
def webserver_is_enabled(name, kind='config'):
|
||||||
|
|||||||
@ -30,7 +30,7 @@ def fixture_patch():
|
|||||||
path.touch()
|
path.touch()
|
||||||
|
|
||||||
with patch('subprocess.call') as subprocess_call, \
|
with patch('subprocess.call') as subprocess_call, \
|
||||||
patch('shutil.chown'):
|
patch('subprocess.run'), patch('shutil.chown'):
|
||||||
subprocess_call.side_effect = side_effect
|
subprocess_call.side_effect = side_effect
|
||||||
yield
|
yield
|
||||||
|
|
||||||
|
|||||||
@ -66,7 +66,7 @@ def fixture_test_configuration(conf_file):
|
|||||||
|
|
||||||
|
|
||||||
def _set_turn_configuration(config=managed_configuration, managed=True):
|
def _set_turn_configuration(config=managed_configuration, managed=True):
|
||||||
with patch('plinth.privileged.service.is_running', return_value=False):
|
with patch('plinth.action_utils.service_is_running', return_value=False):
|
||||||
ejabberd.update_turn_configuration(config, managed=managed)
|
ejabberd.update_turn_configuration(config, managed=managed)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -72,12 +72,14 @@ updated_coturn_configuration = TurnConfiguration(
|
|||||||
|
|
||||||
|
|
||||||
def _set_managed_configuration(config=coturn_configuration):
|
def _set_managed_configuration(config=coturn_configuration):
|
||||||
matrixsynapse.update_turn_configuration(config)
|
with patch('plinth.action_utils.service_try_restart'):
|
||||||
|
matrixsynapse.update_turn_configuration(config)
|
||||||
|
|
||||||
|
|
||||||
def _set_overridden_configuration(
|
def _set_overridden_configuration(
|
||||||
config=overridden_configuration):
|
config=overridden_configuration):
|
||||||
matrixsynapse.update_turn_configuration(config, managed=False)
|
with patch('plinth.action_utils.service_try_restart'):
|
||||||
|
matrixsynapse.update_turn_configuration(config, managed=False)
|
||||||
|
|
||||||
|
|
||||||
def _assert_conf(expected_configuration, expected_managed):
|
def _assert_conf(expected_configuration, expected_managed):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user