Skip to content

Commit

Permalink
Merge pull request #77 from plesk/handle-mailman-service
Browse files Browse the repository at this point in the history
Move Mailman systemd service operations to a separate action
  • Loading branch information
SandakovMM authored Sep 27, 2024
2 parents facd52f + acf4287 commit e9e9500
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions pleskdistup/actions/grub.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

DEBCONF_CMD = "/usr/bin/debconf-show"


class AssertGrubInstallDeviceExists(action.CheckAction):
def __init__(self) -> None:
self.name = "check GRUB installation device exists"
Expand Down
28 changes: 27 additions & 1 deletion pleskdistup/actions/systemd.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ class DisablePleskRelatedServicesDuringUpgrade(action.ActiveAction):

def __init__(self) -> None:
self.name = "disable plesk related services"
# Be cautious when adding the mailman service here. If mailman is not configured, the service will not start.
# The best way to handle mailman is to use the DisableServiceDuringUpgrade action.
plesk_known_systemd_services = [
"crond.service",
"dovecot.service",
"drwebd.service",
"fail2ban.service",
"httpd.service",
"mailman.service",
"mariadb.service",
"named-chroot.service",
"plesk-ext-monitoring-hcd.service",
Expand Down Expand Up @@ -176,6 +177,31 @@ def _revert_action(self) -> action.ActionResult:
return action.ActionResult()


class DisableServiceDuringUpgrade(action.ActiveAction):
target_service: str

def __init__(self, target_service: str) -> None:
self.name = f"handle {target_service} service"
self.target_service = target_service

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

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

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

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


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

Expand Down

0 comments on commit e9e9500

Please sign in to comment.