Skip to content

Commit

Permalink
Move Mailman systemd service operations to a separate action
Browse files Browse the repository at this point in the history
We will now skip any interactions with the Mailman service if
it is not actoive at the start of the conversion.
By default, mailman is not configured and the service will fail to start.
Therefore, attempts to start it during the revert or finishing stage
will also fail.
  • Loading branch information
Mikhail Sandakov committed Sep 25, 2024
1 parent 8a71a4b commit e1b0741
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion pleskdistup/actions/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def __init__(self) -> None:
"drwebd.service",
"fail2ban.service",
"httpd.service",
"mailman.service",
"mariadb.service",
"named-chroot.service",
"plesk-ext-monitoring-hcd.service",
Expand Down Expand Up @@ -176,6 +175,33 @@ def _revert_action(self) -> action.ActionResult:
return action.ActionResult()


# We need to handle the mailman service separately because it is not configured and is stopped by default
# If we try to start an unconfigured service, it will fail, causing issues during the revert and finish stages
class HandleMailmanService(action.ActiveAction):
mailman_service: str

def __init__(self) -> None:
self.name = "handle mailman service"
self.mailman_service = "mailman.service"

def _is_required(self) -> bool:
return systemd.is_service_startable(self.mailman_service) and systemd.is_service_active(self.mailman_service)

def _prepare_action(self) -> action.ActionResult:
util.logged_check_call(["/usr/bin/systemctl", "stop", self.mailman_service])
util.logged_check_call(["/usr/bin/systemctl", "disable", self.mailman_service])
return action.ActionResult()

def _post_action(self) -> action.ActionResult:
util.logged_check_call(["/usr/bin/systemctl", "enable", self.mailman_service])
return action.ActionResult()

def _revert_action(self) -> action.ActionResult:
util.logged_check_call(["/usr/bin/systemctl", "enable", self.mailman_service])
util.logged_check_call(["/usr/bin/systemctl", "start", self.mailman_service])
return action.ActionResult()


class StartPleskBasicServices(action.ActiveAction):
plesk_basic_services: typing.List[str]

Expand Down

0 comments on commit e1b0741

Please sign in to comment.