ok
Direktori : /opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/hooks/plesk/ |
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/clwpos/hooks/plesk/admin_disable_caching.py |
#!/opt/cloudlinux/venv/bin/python3 -sbb # -*- coding: utf-8 -*- # Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved # # Licensed under CLOUD LINUX LICENSE AGREEMENT # http://cloudlinux.com/docs/LICENSE.TXT from __future__ import absolute_import import os import sys from collections import defaultdict from clcommon.cpapi import docroot as get_docroot from clwpos.hooks.lib.admin_disable_caching import ( _run_pre_hook, _run_post_hook ) from clwpos.utils import WposUser, get_parent_pid def main(domains_affected): """ If PHP version has changed we are checking all affected users wps for compatibility Hook is triggered by events -- Update physical hosting This is a universal Cloudlinux hook """ # Create 'users_affected_map' dictionary with: # key - user, # value - user's affected domains and docroots. # Example: { # WposUser('user1'): {'domains_affected': {'user1.com'}, # 'docroots_affected': {'/home/user1/public_html'}}, # WposUser('user2'): {'domains_affected': {'user2.com'}, # 'docroots_affected': {'/home/user2/public_html'}} # } users_affected_map = defaultdict( lambda: {'docroots_affected': set(), 'domains_affected': set()} ) for domain in domains_affected: docroot, username = get_docroot(domain) user = WposUser(username) users_affected_map[user]['domains_affected'].add(domain) users_affected_map[user]['docroots_affected'].add(docroot.rstrip('/')) _run_pre_hook(users_affected_map) _run_post_hook(users_affected_map) if __name__ == '__main__': # Plesk native env vars during event handler execution old_php_handler = os.environ.get('OLD_PHP_HANDLER') new_php_handler = os.environ.get('NEW_PHP_HANDLER') # if handler was not changed, do not execute hook if old_php_handler == new_php_handler: sys.exit(0) # triggers for single domain domain_affected = set() # Plesk native env var during event handler execution domain_affected.add(os.environ.get('NEW_DOMAIN_NAME')) pid = get_parent_pid() # set special envars, further when wp-cli will be called, # presence of these envars will mean to use PHP version that had been written to the special file os.environ.update({'CLWPOS_USE_SAVED_PHP_VERSION': '1', 'CLWPOS_PHP_FILE_ID': str(pid)}) sys.exit(main(domain_affected))