Skip to content

Commit

Permalink
Add an action to restore in-progress motd message on finishing stage
Browse files Browse the repository at this point in the history
It could be useful if we owerride in progress message on signal handling
  • Loading branch information
Mikhail Sandakov committed Oct 18, 2024
1 parent a0dc5fa commit 4a22e77
Showing 1 changed file with 31 additions and 7 deletions.
38 changes: 31 additions & 7 deletions pleskdistup/actions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,7 @@ def _revert_action(self) -> action.ActionResult:
return action.ActionResult()


class AddInProgressSshLoginMessage(action.ActiveAction):
in_progress_message: str

def __init__(self, new_os: str) -> None:
self.name = "add in progress SSH login message"
path_to_util = os.path.abspath(sys.argv[0])
self.in_progress_message = f"""
IN_PROGRESS_MESSAGE_FORMAT = """
===============================================================================
Message from the Plesk dist-upgrader tool:
The server is being converted to {new_os}. Please wait. During the conversion the
Expand All @@ -75,6 +69,15 @@ def __init__(self, new_os: str) -> None:
===============================================================================
"""


class AddInProgressSshLoginMessage(action.ActiveAction):
in_progress_message: str

def __init__(self, new_os: str) -> None:
self.name = "add in progress SSH login message"
path_to_util = os.path.abspath(sys.argv[0])
self.in_progress_message = IN_PROGRESS_MESSAGE_FORMAT.format(new_os=new_os, path_to_util=path_to_util)

def _prepare_action(self) -> action.ActionResult:
log.debug("Adding 'in progress' login message...")
motd.restore_ssh_login_message()
Expand All @@ -89,6 +92,27 @@ def _revert_action(self) -> action.ActionResult:
return action.ActionResult()


class RestoreInProgressSshLoginMessage(action.ActiveAction):
in_progress_message: str

def __init__(self, new_os: str) -> None:
self.name = "restore in progress SSH login message"
path_to_util = os.path.abspath(sys.argv[0])
self.in_progress_message = IN_PROGRESS_MESSAGE_FORMAT.format(new_os=new_os, path_to_util=path_to_util)

def _prepare_action(self) -> action.ActionResult:
return action.ActionResult()

def _post_action(self) -> action.ActionResult:
log.debug("Restore 'in progress' login message...")
motd.restore_ssh_login_message()
motd.add_inprogress_ssh_login_message(self.in_progress_message)
return action.ActionResult()

def _revert_action(self) -> action.ActionResult:
return action.ActionResult()


class DisablePleskSshBanner(action.ActiveAction):
banner_command_path: str

Expand Down

0 comments on commit 4a22e77

Please sign in to comment.