K6h dZddlZddlZddlZddlmZddlmZmZddl m Z m Z m Z ej eZdeezfdZdefdZdefd ZdS) u  This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program.  If not, see . Copyright © 2019 Cloud Linux Software Inc. This software is also available under ImunifyAV commercial license, see N) check_run) WordpressSiteWPSite) PLUGIN_PATHutils PLUGIN_SLUGsitecxKtj|jj}t j|j|}gt j||jddttdd}t j ||}t d|t|d{VdS)zFInstall the Imunify Security WordPress plugin on given WordPress site.plugininstallz --activatez--forcezInstalling wp plugin N)pwdgetpwuiduidpw_namerget_php_binary_pathdomain wp_wrapperdocrootstrrbuild_command_for_userloggerinforr usernamephp_pathargscommands G/opt/imunify360/venv/lib/python3.11/site-packages/imav/wordpress/cli.pyplugin_installr%s|DH%%-H(h??H   (DL 1 1     K        D*8T::G KK111222 G  c^Ktj|jj}t j|j|}gt j||jddtdd}t j ||}t d|t|d{VdS)z;Deactivate the imunify-security wp plugin on given wp site.r uninstallz --deactivatez --allow-rootzDeactivating wp plugin N)r rrrrrrrrrrrrrrs rplugin_deactivater#:s|DH%%-H(h??H   (DL 1 1             D*8T::G KK3'33444 G  r cXKtj|jj}t j|j|}gt j||jdd}t j ||}t d|tj |}|jdkS)zJCheck if WordPress is installed and given site is accessible using WP CLI.corez is-installedz#Checking if WordPress is installed r)r rrrrrrrrrrr subprocessrun returncode)r rrrrresults ris_wordpress_installedr*Ms|DH%%-H(h??H   (DL 1 1    D *8T::G KK?g??@@@ ^G $ $F   !!r )__doc__loggingr r&defence360agent.utilsrimav.model.wordpressrrimav.wordpressrrr getLogger__name__rrr#r*r rr3s* ++++++66666666  8 $ $}v5*-&"}""""""r