Файловый менеджер - Редактировать - /opt/cpmigrate/environments/apacheincludes.py
Ðазад
"""ApacheIncludes Environment module.""" import os from datetime import datetime from environments.base import Environment class ApacheIncludes(Environment): """ Makes a backup of the current Apache includes folder and then copies over the origin server's Apache includes. Will rebuild and restart Apache to ensure it works. """ def __init__(self): Environment.__init__(self) self.includes_path = '/etc/apache2/conf.d/includes' def check(self, _): if self.xfer.ea_version == 4: self.actions.append("+ Back up local apache includes.") self.actions.append("+ Copy origin server apache includes.") self.actions.append("* Rebuild Apache config and restart Apache.") def run(self, _): if self.xfer.ea_version == 4: self.backup_local() self.mv_remote() self.rebuild_apache() self.restart_apache() else: self.info("Skipping ApacheIncludes as origin is EasyApache 3.") def backup_local(self): """Tars up local apache includes as a backup.""" try: self.info("Backing up local apache includes.") date = datetime.now().strftime('%m%d%Y%H%M%S') new_path = f"{self.includes_path}-{date}.bak" os.rename(self.includes_path, new_path) self.info(f"Completed backup of apache includes: {new_path}") except FileNotFoundError: self.error("Could not move includes folder, did not exist.") def mv_remote(self): """Rsync the remote apache includes onto this server.""" path = os.path.join(self.includes_path, '') success = self.xfer.do_rsync( origin=f'{self.xfer.origin_server}:{path}', destination=self.includes_path, name="mv_apacheincludes", ) if success: self.info("EA Profile has been successfully copied over.") return success def rebuild_apache(self): """Rebuilds the httpd configuration.""" self.info("Rebuilding httpd configuration.") ret_code, _ = self.xfer.local_command( ['/scripts/rebuildhttpdconf'], sleep=2 ) if ret_code == 0: self.info("Apache rebuilt successfully.") else: self.error("Apache rebuild failed. Please check manually.") self.xfer.notes.append( "Apache rebuild failed. Please check manually." ) def restart_apache(self): """Restarts Apache to ensure it still works.""" self.info("Restarting Apache.") ret_code = self.xfer.restart_service('httpd') if ret_code == 0: self.info("Apache restarted successfully, no errors.") else: self.error("Apache failed to restart. Please check logs.") self.xfer.notes.append( "Apache failed to restart. Please check logs." )
| ver. 1.1 | |
.
| PHP 8.3.30 | Ð“ÐµÐ½ÐµÑ€Ð°Ñ†Ð¸Ñ Ñтраницы: 0 |
proxy
|
phpinfo
|
ÐаÑтройка