Skip to content

Commit

Permalink
Add an action to make sure www pool is disabled
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Sandakov committed Mar 6, 2024
1 parent 0677539 commit 358e313
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 7 deletions.
38 changes: 31 additions & 7 deletions actions/php.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
# Copyright 1999 - 2023. Plesk International GmbH. All rights reserved.

import collections
import os
import platform
import shutil
import subprocess
import typing

from common import action, log, packages, php, plesk, version
from common import action, log, packages, php, plesk, systemd, version


class AssertMinPhpVersionInstalled(action.CheckAction):
Expand Down Expand Up @@ -149,4 +144,33 @@ def _do_check(self) -> bool:
log.err("Unable to get cronjobs list from plesk database!")
raise RuntimeError("Unable to get cronjobs list from plesk database!") from ex

return False
return False


OS_VENDOR_PHP_FPM_CONFIG = "/etc/php-fpm.d/www.conf"


class FixOsVendorPhpFpmConfiguration(action.ActiveAction):
def __init__(self):
self.name = "fix OS vendor PHP configuration"

def is_required(self) -> bool:
return super().is_required()

def _prepare_action(self):
pass

def _post_action(self):
# Plesk expect www pool to be disabled by default.
# Every distro should has the same configuration generated by Plesk.
# However we store the original configuration in the www.conf.saved_by_psa file.
shutil.move(f"{OS_VENDOR_PHP_FPM_CONFIG}.rpmnew", f"{OS_VENDOR_PHP_FPM_CONFIG}.saved_by_psa")

if systemd.is_service_exists("php-fpm") and systemd.is_service_active("php-fpm"):
systemd.restart_services(["php-fpm"])

def _revert_action(self):
pass

def estimate_post_time(self):
return 1
1 change: 1 addition & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def construct_actions(options: typing.Any, stage_flag: Stages) -> typing.Dict[in
actions.FixNamedConfig(),
actions.RecreateAwstatConfigurationFiles(),
actions.IncreaseDovecotDHParameters(),
actions.FixOsVendorPhpFpmConfiguration(),
],
3: [
actions.DisablePleskSshBanner(),
Expand Down

0 comments on commit 358e313

Please sign in to comment.