Skip to content

Commit

Permalink
Skip service_resume if already enabled
Browse files Browse the repository at this point in the history
Repeatedly calling service_resume for a service that
is already enabled can lead to unintended consequences.
This adds a check to only resume a serice if it is not
enabled.

Related-Bug: #2058505
  • Loading branch information
dosaboy committed Mar 22, 2024
1 parent 511bc03 commit f570da3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions charmhelpers/core/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,11 @@ def service_resume(service_name, init_dir="/etc/init",
parameters to the init system's commandline. kwargs
are ignored for systemd enabled systems.
"""
if service('is-enabled', service_name):
log('service {} already enabled - skipping resume'.
format(service_name), level=INFO)
return

upstart_file = os.path.join(init_dir, "{}.conf".format(service_name))
sysv_file = os.path.join(initd_dir, service_name)
if init_is_systemd(service_name=service_name):
Expand Down

0 comments on commit f570da3

Please sign in to comment.