def updatewpuserpassword(self, ee_domain, ee_site_webroot):

    ee_wp_user = ""
    ee_wp_pass = ""
    EEFileUtils.chdir(self, "{0}/htdocs/".format(ee_site_webroot))

    # Check if ee_domain is wordpress install
    try:
        is_wp = EEShellExec.cmd_exec(self, "wp --allow-root core" " version")
    except CommandExecutionError as e:
        raise SiteError("is wordpress site? check command failed ")

    # Exit if ee_domain is not wordpress install
    if not is_wp:
        Log.error(self, "{0} does not seem to be a WordPress site".format(ee_domain))

    try:
        ee_wp_user = input("Provide WordPress user name [admin]: ")
    except Exception as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "\nCould not update password")

    if ee_wp_user == "?":
        Log.info(self, "Fetching WordPress user list")
        try:
            EEShellExec.cmd_exec(self, "wp --allow-root user list " "--fields=user_login | grep -v user_login")
        except CommandExecutionError as e:
            raise SiteError("fetch wp userlist command failed")

    if not ee_wp_user:
        ee_wp_user = "******"

    try:
        is_user_exist = EEShellExec.cmd_exec(
            self, "wp --allow-root user list " "--fields=user_login | grep {0}$ ".format(ee_wp_user)
        )
    except CommandExecutionError as e:
        raise SiteError("if wp user exists check command failed")

    if is_user_exist:
        try:
            ee_wp_pass = getpass.getpass(prompt="Provide password for " "{0} user: "******"Provide password for " "{0} user: "******"{0}".format(e))
            raise SiteError("failed to read password input ")

        try:
            EEShellExec.cmd_exec(
                self, "wp --allow-root user update {0}" "  --user_pass={1}".format(ee_wp_user, ee_wp_pass)
            )
        except CommandExecutionError as e:
            raise SiteError("wp user password update command failed")
        Log.info(self, "Password updated successfully")

    else:
        Log.error(self, "Invalid WordPress user {0} for {1}.".format(ee_wp_user, ee_domain))
def uninstallwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.debug(self, "Uninstalling plugin {0}".format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root uninstall "
                         "{0}".format(plugin_name),
                         errormsg="Unable to UnInstall plugin {0}"
                         .format(plugin_name))
def uninstallwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.debug(self, "Uninstalling plugin {0}".format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    EEShellExec.cmd_exec(
        self,
        "php /usr/bin/wp plugin --allow-root uninstall "
        "{0}".format(plugin_name),
        errormsg="Unable to UnInstall plugin {0}".format(plugin_name))
def setupwordpressnetwork(self, data):
    ee_site_webroot = data['webroot']
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.info(self, "Setting up WordPress Network \t", end='')
    EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
                         ' --title=\'{0}\' {subdomains}'
                         .format(data['www_domain'], subdomains='--subdomains'
                                 if not data['wpsubdir'] else ''))
    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
def updatewpuserpassword(self, ee_domain, ee_site_webroot):

    ee_wp_user = ''
    ee_wp_pass = ''
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))

    # Check if ee_domain is wordpress install
    is_wp = EEShellExec.cmd_exec(
        self, "wp --allow-root core"
        " version",
        errormsg="{0} : Unable to check if wp install".format(ee_domain))

    # Exit if ee_domain is not wordpress install
    if not is_wp:
        Log.error(self,
                  "{0} does not seem to be a WordPress site".format(ee_domain))

    try:
        ee_wp_user = input("Provide WordPress user name [admin]: ")
    except Exception as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "\nCould not update password")

    if ee_wp_user == "?":
        Log.info(self, "Fetching WordPress user list")
        EEShellExec.cmd_exec(self, "wp --allow-root user list "
                             "--fields=user_login | grep -v user_login",
                             errormsg="Unable to Fetch users list")

    if not ee_wp_user:
        ee_wp_user = '******'

    is_user_exist = EEShellExec.cmd_exec(
        self, "wp --allow-root user list "
        "--fields=user_login | grep {0}$ ".format(ee_wp_user))

    if is_user_exist:
        try:
            ee_wp_pass = getpass.getpass(prompt="Provide password for "
                                         "{0} user: "******"{0}".format(e))
            Log.error(self, "Could not update password")

        if len(ee_wp_pass) > 8:
            EEShellExec.cmd_exec(
                self, "wp --allow-root user update {0}"
                "  --user_pass={1}".format(ee_wp_user, ee_wp_pass))
            Log.info(self, "Password updated successfully")
        else:
            Log.error(
                self, "Password Unchanged. Hint : Your password must be "
                "8 characters long")
    else:
        Log.error(
            self, "Invalid WordPress user {0} for {1}.".format(
                ee_wp_user, ee_domain))
def updatewpuserpassword(self, ee_domain, ee_site_webroot):

    ee_wp_user = ''
    ee_wp_pass = ''
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))

    # Check if ee_domain is wordpress install
    is_wp = EEShellExec.cmd_exec(self, "wp --allow-root core"
                                 " version",
                                 errormsg="{0} : Unable to check if wp install"
                                 .format(ee_domain))

    # Exit if ee_domain is not wordpress install
    if not is_wp:
        Log.error(self, "{0} does not seem to be a WordPress site"
                  .format(ee_domain))

    try:
        ee_wp_user = input("Provide WordPress user name [admin]: ")
    except Exception as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "\nCould not update password")

    if ee_wp_user == "?":
        Log.info(self, "Fetching WordPress user list")
        EEShellExec.cmd_exec(self, "wp --allow-root user list "
                             "--fields=user_login | grep -v user_login",
                             errormsg="Unable to Fetch users list")

    if not ee_wp_user:
        ee_wp_user = '******'

    is_user_exist = EEShellExec.cmd_exec(self, "wp --allow-root user list "
                                         "--fields=user_login | grep {0}$ "
                                         .format(ee_wp_user))

    if is_user_exist:
        try:
            ee_wp_pass = getpass.getpass(prompt="Provide password for "
                                         "{0} user: "******"{0}".format(e))
            Log.error(self, "Could not update password")

        if len(ee_wp_pass) > 8:
            EEShellExec.cmd_exec(self, "wp --allow-root user update {0}"
                                 "  --user_pass={1}"
                                 .format(ee_wp_user, ee_wp_pass))
            Log.info(self, "Password updated successfully")
        else:
            Log.error(self, "Password Unchanged. Hint : Your password must be "
                      "8 characters long")
    else:
        Log.error(self, "Invalid WordPress user {0} for {1}."
                  .format(ee_wp_user, ee_domain))
def setupwordpressnetwork(self, data):
    ee_site_webroot = data['webroot']
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.info(self, "Setting up WordPress Network \t", end='')
    EEShellExec.cmd_exec(
        self, 'wp --allow-root core multisite-convert'
        ' --title={0} {subdomains}'.format(
            data['www_domain'],
            subdomains='--subdomains' if not data['wpsubdir'] else ''))
    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
Exemple #8
0
def uninstallwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.debug(self, "Uninstalling plugin {0}, please wait..."
              .format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    try:
        EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin "
                             "--allow-root uninstall "
                             "{0}".format(plugin_name))
    except CommandExecutionError as e:
        raise SiteError("plugin uninstall failed")
Exemple #9
0
def uninstallwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.debug(self,
              "Uninstalling plugin {0}, please wait...".format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    try:
        EEShellExec.cmd_exec(
            self, "php /usr/bin/wp plugin "
            "--allow-root uninstall "
            "{0}".format(plugin_name))
    except CommandExecutionError as e:
        raise SiteError("plugin uninstall failed")
Exemple #10
0
def setupwordpressnetwork(self, data):
    ee_site_webroot = data['webroot']
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.info(self, "Setting up WordPress Network \t", end='')
    try:
        EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
                             ' --title=\'{0}\' {subdomains}'
                             .format(data['www_domain'],
                                     subdomains='--subdomains'
                                     if not data['wpsubdir'] else ''))
    except CommandExecutionError as e:
        Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
        raise SiteError("setup wordpress network failed")
    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
Exemple #11
0
def setupwordpressnetwork(self, data):
    ee_site_webroot = data['webroot']
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.info(self, "Setting up WordPress Network \t", end='')
    try:
        EEShellExec.cmd_exec(self, 'wp --allow-root core multisite-convert'
                             ' --title=\'{0}\' {subdomains}'
                             .format(data['www_domain'],
                                     subdomains='--subdomains'
                                     if not data['wpsubdir'] else ''))
    except CommandExecutionError as e:
        Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
        raise SiteError("setup wordpress network failed")
    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
Exemple #12
0
def installwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.info(self, "Installing plugin {0}".format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root install "
                         "{0}".format(plugin_name),
                         errormsg="Unable to Install plugin {0}"
                         .format(plugin_name))

    EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin --allow-root activate "
                         "{0} {na}"
                         .format(plugin_name,
                                 na='--network' if data['multisite'] else ''),
                         errormsg="Unable to Activate plugin {0}"
                         .format(plugin_name))
def installwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.debug(self, "Installing plugin {0}".format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    EEShellExec.cmd_exec(
        self,
        "php /usr/bin/wp plugin --allow-root install "
        "{0}".format(plugin_name),
        errormsg="Unable to Install plugin {0}".format(plugin_name))

    EEShellExec.cmd_exec(
        self,
        "php /usr/bin/wp plugin --allow-root activate "
        "{0} {na}".format(plugin_name,
                          na='--network' if data['multisite'] else ''),
        errormsg="Unable to Activate plugin {0}".format(plugin_name))
def uninstallwp_plugin(self, plugin_name, data):
    ee_site_webroot = data["webroot"]
    Log.debug(self, "Uninstalling plugin {0}, please wait...".format(plugin_name))
    EEFileUtils.chdir(self, "{0}/htdocs/".format(ee_site_webroot))
    Log.info(self, "Uninstalling plugin {0}, please wait...".format(plugin_name))
    try:
        EEShellExec.cmd_exec(
            self,
            "php {0} plugin ".format(EEVariables.ee_wpcli_path) + "--allow-root deactivate " "{0}".format(plugin_name),
        )

        EEShellExec.cmd_exec(
            self,
            "php {0} plugin ".format(EEVariables.ee_wpcli_path) + "--allow-root uninstall " "{0}".format(plugin_name),
        )
    except CommandExecutionError as e:
        raise SiteError("plugin uninstall failed")
Exemple #15
0
def uninstallwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.debug(self, "Uninstalling plugin {0}, please wait..."
              .format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.info(self, "Uninstalling plugin {0}, please wait..."
             .format(plugin_name))
    try:
        EEShellExec.cmd_exec(self, "php {0} plugin "
                             .format(EEVariables.ee_wpcli_path)
                             + "--allow-root deactivate "
                             "{0}".format(plugin_name))

        EEShellExec.cmd_exec(self, "php {0} plugin "
                             .format(EEVariables.ee_wpcli_path)
                             + "--allow-root uninstall "
                             "{0}".format(plugin_name))
    except CommandExecutionError as e:
        raise SiteError("plugin uninstall failed")
Exemple #16
0
def installwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.info(self, "Installing plugin {0}, please wait...".format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    try:
        EEShellExec.cmd_exec(
            self, "php /usr/bin/wp plugin "
            "--allow-root install "
            "{0}".format(plugin_name))
    except CommandExecutionError as e:
        raise SiteError("plugin installation failed")

    try:
        EEShellExec.cmd_exec(
            self, "php /usr/bin/wp plugin "
            "--allow-root activate "
            "{0} {na}".format(plugin_name,
                              na='--network' if data['multisite'] else ''))
    except CommandExecutionError as e:
        raise SiteError("plugin activation failed")
def setupwordpressnetwork(self, data):
    ee_site_webroot = data["webroot"]
    EEFileUtils.chdir(self, "{0}/htdocs/".format(ee_site_webroot))
    Log.info(self, "Setting up WordPress Network \t", end="")
    try:
        if EEShellExec.cmd_exec(
            self,
            "wp --allow-root core multisite-convert"
            " --title='{0}' {subdomains}".format(
                data["www_domain"], subdomains="--subdomains" if not data["wpsubdir"] else ""
            ),
        ):
            pass
        else:
            Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
            raise SiteError("setup wordpress network failed")

    except CommandExecutionError as e:
        Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
        raise SiteError("setup wordpress network failed")
    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")
Exemple #18
0
def installwp_plugin(self, plugin_name, data):
    ee_site_webroot = data['webroot']
    Log.info(self, "Installing plugin {0}, please wait..."
             .format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    try:
        EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin "
                             "--allow-root install "
                             "{0}".format(plugin_name))
    except CommandExecutionError as e:
        raise SiteError("plugin installation failed")

    try:
        EEShellExec.cmd_exec(self, "php /usr/bin/wp plugin "
                             "--allow-root activate "
                             "{0} {na}"
                             .format(plugin_name,
                                     na='--network' if data['multisite']
                                     else ''
                                     ))
    except CommandExecutionError as e:
        raise SiteError("plugin activation failed")
def installwp_plugin(self, plugin_name, data):
    ee_site_webroot = data["webroot"]
    Log.info(self, "Installing plugin {0}, please wait...".format(plugin_name))
    EEFileUtils.chdir(self, "{0}/htdocs/".format(ee_site_webroot))
    try:
        EEShellExec.cmd_exec(
            self,
            "php {0} plugin ".format(EEVariables.ee_wpcli_path) + "--allow-root install " "{0}".format(plugin_name),
        )
    except CommandExecutionError as e:
        raise SiteError("plugin installation failed")

    try:
        EEShellExec.cmd_exec(
            self,
            "php {0} plugin ".format(EEVariables.ee_wpcli_path) + "--allow-root activate "
            "{0} {na}".format(plugin_name, na="--network" if data["multisite"] else ""),
        )
    except CommandExecutionError as e:
        raise SiteError("plugin activation failed")

    return 1
def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
    ee_site_webroot = data["webroot"]
    Log.info(self, "Setting plugin {0}, please wait...".format(plugin_name))
    EEFileUtils.chdir(self, "{0}/htdocs/".format(ee_site_webroot))

    if not data["multisite"]:
        try:
            EEShellExec.cmd_exec(
                self,
                "php {0} ".format(EEVariables.ee_wpcli_path) + "--allow-root option update "
                "{0} '{1}' --format=json".format(plugin_option, plugin_data),
            )
        except CommandExecutionError as e:
            raise SiteError("plugin setup failed")
    else:
        try:
            EEShellExec.cmd_exec(
                self,
                "php {0} ".format(EEVariables.ee_wpcli_path) + "--allow-root network meta update 1 "
                "{0} '{1}' --format=json".format(plugin_option, plugin_data),
            )
        except CommandExecutionError as e:
            raise SiteError("plugin setup failed")
Exemple #21
0
    def cd(self):
        if not self.app.pargs.site_name:
            try:
                while not self.app.pargs.site_name:
                    self.app.pargs.site_name = (input('Enter site name : ')
                                                .strip())
            except IOError as e:
                Log.error(self, 'Unable to read input, please try again')

        self.app.pargs.site_name = self.app.pargs.site_name.strip()
        (ee_domain, ee_www_domain) = ValidateDomain(self.app.pargs.site_name)

        if not check_domain_exists(self, ee_domain):
            Log.error(self, "site {0} does not exist".format(ee_domain))

        ee_site_webroot = getSiteInfo(self, ee_domain).site_path
        EEFileUtils.chdir(self, ee_site_webroot)

        try:
            subprocess.call(['bash'])
        except OSError as e:
            Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
            Log.error(self, "unable to change directory")
Exemple #22
0
def setupwp_plugin(self, plugin_name, plugin_option, plugin_data, data):
    ee_site_webroot = data['webroot']
    Log.info(self, "Setting plugin {0}, please wait..."
             .format(plugin_name))
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))

    if not data['multisite']:
        try:
            EEShellExec.cmd_exec(self, "php {0} "
                                 .format(EEVariables.ee_wpcli_path)
                                 + "--allow-root option update "
                                 "{0} \'{1}\' --format=json".format(plugin_option, plugin_data))
        except CommandExecutionError as e:
            raise SiteError("plugin setup failed")
    else:
        try:
            EEShellExec.cmd_exec(self, "php {0} "
                                 .format(EEVariables.ee_wpcli_path)
                                 + "--allow-root network meta update 1 "
                                  "{0} \'{1}\' --format=json"
                                 .format(plugin_option, plugin_data
                                         ))
        except CommandExecutionError as e:
            raise SiteError("plugin setup failed")
Exemple #23
0
def updatewpuserpassword(self, ee_domain, ee_site_webroot):

    ee_wp_user = ''
    ee_wp_pass = ''
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))

    # Check if ee_domain is wordpress install
    try:
        is_wp = EEShellExec.cmd_exec(self, "wp --allow-root core"
                                     " version")
    except CommandExecutionError as e:
        raise SiteError("is wordpress site? check command failed ")

    # Exit if ee_domain is not wordpress install
    if not is_wp:
        Log.error(self, "{0} does not seem to be a WordPress site"
                  .format(ee_domain))

    try:
        ee_wp_user = input("Provide WordPress user name [admin]: ")
    except Exception as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "\nCould not update password")

    if ee_wp_user == "?":
        Log.info(self, "Fetching WordPress user list")
        try:
            EEShellExec.cmd_exec(self, "wp --allow-root user list "
                                 "--fields=user_login | grep -v user_login")
        except CommandExecutionError as e:
            raise SiteError("fetch wp userlist command failed")

    if not ee_wp_user:
        ee_wp_user = '******'

    try:
        is_user_exist = EEShellExec.cmd_exec(self, "wp --allow-root user list "
                                             "--fields=user_login | grep {0}$ "
                                             .format(ee_wp_user))
    except CommandExecutionError as e:
        raise SiteError("if wp user exists check command failed")

    if is_user_exist:
        try:
            ee_wp_pass = getpass.getpass(prompt="Provide password for "
                                         "{0} user: "******"{0}".format(e))
            raise SiteError("failed to read password input ")

        try:
            EEShellExec.cmd_exec(self, "wp --allow-root user update {0}"
                                 "  --user_pass={1}"
                                 .format(ee_wp_user, ee_wp_pass))
        except CommandExecutionError as e:
            raise SiteError("wp user password update command failed")
        Log.info(self, "Password updated successfully")

    else:
        Log.error(self, "Invalid WordPress user {0} for {1}."
                  .format(ee_wp_user, ee_domain))
def setupwordpress(self, data):
    ee_domain_name = data["site_name"]
    ee_site_webroot = data["webroot"]
    prompt_wpprefix = self.app.config.get("wordpress", "prefix")
    ee_wp_user = self.app.config.get("wordpress", "user")
    ee_wp_pass = self.app.config.get("wordpress", "password")
    ee_wp_email = self.app.config.get("wordpress", "email")
    # Random characters
    ee_random = "".join(random.sample(string.ascii_uppercase + string.ascii_lowercase + string.digits, 15))
    ee_wp_prefix = ""
    # ee_wp_user = ''
    # ee_wp_pass = ''

    if "wp-user" in data.keys() and data["wp-user"]:
        ee_wp_user = data["wp-user"]
    if "wp-email" in data.keys() and data["wp-email"]:
        ee_wp_email = data["wp-email"]
    if "wp-pass" in data.keys() and data["wp-pass"]:
        ee_wp_pass = data["wp-pass"]

    Log.info(self, "Downloading Wordpress \t\t", end="")
    EEFileUtils.chdir(self, "{0}/htdocs/".format(ee_site_webroot))
    try:
        if EEShellExec.cmd_exec(self, "wp --allow-root core" " download"):
            pass
        else:
            Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
            raise SiteError("download wordpress core failed")
    except CommandExecutionError as e:
        Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
        raise SiteError(self, "download wordpress core failed")

    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")

    if not (data["ee_db_name"] and data["ee_db_user"] and data["ee_db_pass"]):
        data = setupdatabase(self, data)
    if prompt_wpprefix == "True" or prompt_wpprefix == "true":
        try:
            ee_wp_prefix = input("Enter the WordPress table prefix [wp_]: ")
            while not re.match("^[A-Za-z0-9_]*$", ee_wp_prefix):
                Log.warn(self, "table prefix can only " "contain numbers, letters, and underscores")
                ee_wp_prefix = input("Enter the WordPress table prefix [wp_]: ")
        except EOFError as e:
            Log.debug(self, "{0}".format(e))
            raise SiteError("input table prefix failed")

    if not ee_wp_prefix:
        ee_wp_prefix = "wp_"

    # Modify wp-config.php & move outside the webroot

    EEFileUtils.chdir(self, "{0}/htdocs/".format(ee_site_webroot))
    Log.debug(self, "Setting up wp-config file")
    if not data["multisite"]:
        Log.debug(self, "Generating wp-config for WordPress Single site")
        Log.debug(
            self,
            'bash -c "php {0} --allow-root '.format(EEVariables.ee_wpcli_path)
            + "core config "
            + "--dbname='{0}' --dbprefix='{1}' --dbuser='******' "
            "--dbhost='{3}' ".format(data["ee_db_name"], ee_wp_prefix, data["ee_db_user"], data["ee_db_host"])
            + "--dbpass= "******"'.format(data["ee_db_pass"], "\n\ndefine('WP_DEBUG', false);"),
        )
        try:
            if EEShellExec.cmd_exec(
                self,
                'bash -c "php {0} --allow-root'.format(EEVariables.ee_wpcli_path)
                + " core config "
                + "--dbname='{0}' --dbprefix='{1}' "
                "--dbuser='******' --dbhost='{3}' ".format(
                    data["ee_db_name"], ee_wp_prefix, data["ee_db_user"], data["ee_db_host"]
                )
                + "--dbpass='******' "
                '--extra-php<<PHP \n {1} {redissalt}\nPHP"'.format(
                    data["ee_db_pass"],
                    "\n\ndefine('WP_DEBUG', false);",
                    redissalt="\n\ndefine( 'WP_CACHE_KEY_SALT', '{0}:' );".format(ee_domain_name)
                    if data["wpredis"]
                    else "",
                ),
                log=False,
            ):
                pass
            else:
                raise SiteError("generate wp-config failed for wp single site")
        except CommandExecutionError as e:
            raise SiteError("generate wp-config failed for wp single site")
    else:
        Log.debug(self, "Generating wp-config for WordPress multisite")
        Log.debug(
            self,
            'bash -c "php {0} --allow-root '.format(EEVariables.ee_wpcli_path)
            + "core config "
            + "--dbname='{0}' --dbprefix='{1}' --dbhost='{2}' ".format(
                data["ee_db_name"], ee_wp_prefix, data["ee_db_host"]
            )
            + "--dbuser='******' --dbpass= "******"'.format(
                data["ee_db_user"],
                data["ee_db_pass"],
                "\ndefine('WP_ALLOW_MULTISITE', " "true);",
                "\ndefine('WPMU_ACCEL_REDIRECT'," " true);",
                "\n\ndefine('WP_DEBUG', false);",
            ),
        )
        try:
            if EEShellExec.cmd_exec(
                self,
                'bash -c "php {0} --allow-root'.format(EEVariables.ee_wpcli_path)
                + " core config "
                + "--dbname='{0}' --dbprefix='{1}' "
                "--dbhost='{2}' ".format(data["ee_db_name"], ee_wp_prefix, data["ee_db_host"])
                + "--dbuser='******' --dbpass='******' "
                '--extra-php<<PHP \n {2} {3} {4} {redissalt}\nPHP"'.format(
                    data["ee_db_user"],
                    data["ee_db_pass"],
                    "\ndefine('WP_ALLOW_MULTISITE', " "true);",
                    "\ndefine('WPMU_ACCEL_REDIRECT'," " true);",
                    "\n\ndefine('WP_DEBUG', false);",
                    redissalt="\n\ndefine( 'WP_CACHE_KEY_SALT', '{0}:' );".format(ee_domain_name)
                    if data["wpredis"]
                    else "",
                ),
                log=False,
            ):
                pass
            else:
                raise SiteError("generate wp-config failed for wp multi site")
        except CommandExecutionError as e:
            raise SiteError("generate wp-config failed for wp multi site")

    # EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
    #                   os.path.abspath(os.path.join(os.getcwd(), os.pardir)))

    try:
        import shutil

        Log.debug(
            self,
            "Moving file from {0} to {1}".format(
                os.getcwd() + "/wp-config.php", os.path.abspath(os.path.join(os.getcwd(), os.pardir))
            ),
        )
        shutil.move(os.getcwd() + "/wp-config.php", os.path.abspath(os.path.join(os.getcwd(), os.pardir)))
    except Exception as e:
        Log.error(
            self,
            "Unable to move file from {0} to {1}".format(
                os.getcwd() + "/wp-config.php", os.path.abspath(os.path.join(os.getcwd(), os.pardir))
            ),
            False,
        )
        raise SiteError("Unable to move wp-config.php")

    if not ee_wp_user:
        ee_wp_user = EEVariables.ee_user
        while not ee_wp_user:
            Log.warn(
                self,
                "Username can have only alphanumeric"
                "characters, spaces, underscores, hyphens,"
                "periods and the @ symbol.",
            )
            try:
                ee_wp_user = input("Enter WordPress username: "******"{0}".format(e))
                raise SiteError("input wordpress username failed")
    if not ee_wp_pass:
        ee_wp_pass = ee_random

    if not ee_wp_email:
        ee_wp_email = EEVariables.ee_email
        while not ee_wp_email:
            try:
                ee_wp_email = input("Enter WordPress email: ")
            except EOFError as e:
                Log.debug(self, "{0}".format(e))
                raise SiteError("input wordpress username failed")

    try:
        while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$", ee_wp_email):
            Log.info(self, "EMail not Valid in config, " "Please provide valid email id")
            ee_wp_email = input("Enter your email: ")
    except EOFError as e:
        Log.debug(self, "{0}".format(e))
        raise SiteError("input WordPress user email failed")

    Log.debug(self, "Setting up WordPress tables")

    if not data["multisite"]:
        Log.debug(self, "Creating tables for WordPress Single site")
        Log.debug(
            self,
            "php {0} --allow-root core install ".format(EEVariables.ee_wpcli_path)
            + "--url='{0}' --title='{0}' --admin_name='{1}' ".format(data["www_domain"], ee_wp_user)
            + "--admin_password= --admin_email='{1}'".format(ee_wp_pass, ee_wp_email),
        )
        try:
            if EEShellExec.cmd_exec(
                self,
                "php {0} --allow-root core ".format(EEVariables.ee_wpcli_path) + "install --url='{0}' --title='{0}' "
                "--admin_name='{1}' ".format(data["www_domain"], ee_wp_user) + "--admin_password='******' "
                "--admin_email='{1}'".format(ee_wp_pass, ee_wp_email),
                log=False,
            ):
                pass
            else:
                raise SiteError("setup wordpress tables failed for single site")
        except CommandExecutionError as e:
            raise SiteError("setup wordpress tables failed for single site")
    else:
        Log.debug(self, "Creating tables for WordPress multisite")
        Log.debug(
            self,
            "php {0} --allow-root ".format(EEVariables.ee_wpcli_path) + "core multisite-install "
            "--url='{0}' --title='{0}' --admin_name='{1}' ".format(data["www_domain"], ee_wp_user)
            + "--admin_password= --admin_email='{1}' "
            "{subdomains}".format(ee_wp_pass, ee_wp_email, subdomains="--subdomains" if not data["wpsubdir"] else ""),
        )
        try:
            if EEShellExec.cmd_exec(
                self,
                "php {0} --allow-root ".format(EEVariables.ee_wpcli_path) + "core multisite-install "
                "--url='{0}' --title='{0}' "
                "--admin_name='{1}' ".format(data["www_domain"], ee_wp_user) + "--admin_password='******' "
                "--admin_email='{1}' "
                "{subdomains}".format(
                    ee_wp_pass, ee_wp_email, subdomains="--subdomains" if not data["wpsubdir"] else ""
                ),
                log=False,
            ):
                pass
            else:
                raise SiteError("setup wordpress tables failed for wp multi site")
        except CommandExecutionError as e:
            raise SiteError("setup wordpress tables failed for wp multi site")

    Log.debug(self, "Updating WordPress permalink")
    try:
        EEShellExec.cmd_exec(
            self,
            " php {0} --allow-root ".format(EEVariables.ee_wpcli_path) + "rewrite structure "
            "/%year%/%monthnum%/%day%/%postname%/",
        )
    except CommandExecutionError as e:
        raise SiteError("Update wordpress permalinks failed")

    """Install nginx-helper plugin """
    installwp_plugin(self, "nginx-helper", data)
    if data["wpfc"]:
        plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_fastcgi","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
        setupwp_plugin(self, "nginx-helper", "rt_wp_nginx_helper_options", plugin_data, data)
    elif data["wpredis"]:
        plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_redis","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
        setupwp_plugin(self, "nginx-helper", "rt_wp_nginx_helper_options", plugin_data, data)

    """Install Wp Super Cache"""
    if data["wpsc"]:
        installwp_plugin(self, "wp-super-cache", data)

    """Install Redis Cache"""
    if data["wpredis"]:
        installwp_plugin(self, "redis-cache", data)

    """Install W3 Total Cache"""
    if data["w3tc"] or data["wpfc"]:
        installwp_plugin(self, "w3-total-cache", data)

    wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass, wp_email=ee_wp_email)

    return wp_creds
Exemple #25
0
def setupwordpress(self, data):
    ee_domain_name = data['site_name']
    ee_site_webroot = data['webroot']
    prompt_wpprefix = self.app.config.get('wordpress', 'prefix')
    ee_wp_user = self.app.config.get('wordpress', 'user')
    ee_wp_pass = self.app.config.get('wordpress', 'password')
    ee_wp_email = self.app.config.get('wordpress', 'email')
    # Random characters
    ee_random = (''.join(random.sample(string.ascii_uppercase +
                 string.ascii_lowercase + string.digits, 15)))
    ee_wp_prefix = ''
    # ee_wp_user = ''
    # ee_wp_pass = ''

    if 'wp-user' in data.keys() and data['wp-user']:
        ee_wp_user = data['wp-user']
    if 'wp-email' in data.keys() and data['wp-email']:
        ee_wp_email = data['wp-email']
    if 'wp-pass' in data.keys() and data['wp-pass']:
        ee_wp_pass = data['wp-pass']

    Log.info(self, "Downloading Wordpress \t\t", end='')
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    try:
        EEShellExec.cmd_exec(self, "wp --allow-root core"
                             " download")
    except CommandExecutionError as e:
        Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
        raise SiteError(self, "download wordpress core failed")

    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")

    if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']):
        data = setupdatabase(self, data)
    if prompt_wpprefix == 'True' or prompt_wpprefix == 'true':
        try:
            ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ')
            while not re.match('^[A-Za-z0-9_]*$', ee_wp_prefix):
                Log.warn(self, "table prefix can only "
                         "contain numbers, letters, and underscores")
                ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: '
                                     )
        except EOFError as e:
            Log.debug(self, "{0}".format(e))
            raise SiteError("input table prefix failed")

    if not ee_wp_prefix:
        ee_wp_prefix = 'wp_'

    # Modify wp-config.php & move outside the webroot

    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.debug(self, "Setting up wp-config file")
    if not data['multisite']:
        Log.debug(self, "Generating wp-config for WordPress Single site")
        Log.debug(self, "bash -c \"php {0} --allow-root "
                  .format(EEVariables.ee_wpcli_path)
                  + "core config "
                  + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
                  "--dbhost=\'{3}\' "
                  .format(data['ee_db_name'], ee_wp_prefix,
                          data['ee_db_user'], data['ee_db_host'])
                  + "--dbpass= "******"--extra-php<<PHP \n {1}\nPHP\""
                  .format(data['ee_db_pass'],
                          "\n\ndefine(\'WP_DEBUG\', false);"))
        try:
            EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
                                 .format(EEVariables.ee_wpcli_path)
                                 + " core config "
                                 + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
                                 "--dbuser=\'{2}\' --dbhost=\'{3}\' "
                                 .format(data['ee_db_name'], ee_wp_prefix,
                                         data['ee_db_user'], data['ee_db_host']
                                         )
                                 + "--dbpass=\'{0}\' "
                                   "--extra-php<<PHP \n {1} {redissalt}\nPHP\""
                                   .format(data['ee_db_pass'],
                                           "\n\ndefine(\'WP_DEBUG\', false);",
                                           redissalt="\n\ndefine( \'WP_CACHE_KEY_SALT\', \'{0}:\' );"
                                                      .format(ee_domain_name) if data['wpredis'] 
                                                      else ''),
                                   log=False
                                 )
        except CommandExecutionError as e:
                raise SiteError("generate wp-config failed for wp single site")
    else:
        Log.debug(self, "Generating wp-config for WordPress multisite")
        Log.debug(self, "bash -c \"php {0} --allow-root "
                  .format(EEVariables.ee_wpcli_path)
                  + "core config "
                  + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
                  .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
                  + "--dbuser=\'{0}\' --dbpass= "******"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
                  .format(data['ee_db_user'], data['ee_db_pass'],
                          "\ndefine(\'WP_ALLOW_MULTISITE\', "
                          "true);",
                          "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
                          " true);",
                          "\n\ndefine(\'WP_DEBUG\', false);"))
        try:
            EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
                                 .format(EEVariables.ee_wpcli_path)
                                 + " core config "
                                 + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
                                 "--dbhost=\'{2}\' "
                                 .format(data['ee_db_name'], ee_wp_prefix,
                                         data['ee_db_host'])
                                 + "--dbuser=\'{0}\' --dbpass=\'{1}\' "
                                   "--extra-php<<PHP \n {2} {3} {4} {redissalt}\nPHP\""
                                 .format(data['ee_db_user'],
                                         data['ee_db_pass'],
                                         "\ndefine(\'WP_ALLOW_MULTISITE\', "
                                         "true);",
                                         "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
                                         " true);",
                                         "\n\ndefine(\'WP_DEBUG\', false);",
                                         redissalt="\n\ndefine( \'WP_CACHE_KEY_SALT\', \'{0}:\' );"
                                                      .format(ee_domain_name) if data['wpredis'] 
                                                      else ''),
                                 log=False
                                 )
        except CommandExecutionError as e:
                raise SiteError("generate wp-config failed for wp multi site")

    EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
                       os.path.abspath(os.path.join(os.getcwd(), os.pardir)))

    if not ee_wp_user:
        ee_wp_user = EEVariables.ee_user
        while not ee_wp_user:
            Log.warn(self, "Username can have only alphanumeric"
                     "characters, spaces, underscores, hyphens,"
                     "periods and the @ symbol.")
            try:
                ee_wp_user = input('Enter WordPress username: '******'Enter WordPress email: ')
            except EOFError as e:
                Log.debug(self, "{0}".format(e))
                raise SiteError("input wordpress username failed")

    try:
        while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
                           ee_wp_email):
            Log.info(self, "EMail not Valid in config, "
                     "Please provide valid email id")
            ee_wp_email = input("Enter your email: ")
    except EOFError as e:
        Log.debug(self, "{0}".format(e))
        raise SiteError("input WordPress user email failed")

    Log.debug(self, "Setting up WordPress tables")

    if not data['multisite']:
        Log.debug(self, "Creating tables for WordPress Single site")
        Log.debug(self, "php {0} --allow-root core install "
                  .format(EEVariables.ee_wpcli_path)
                  + "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
                  .format(data['www_domain'], ee_wp_user)
                  + "--admin_password= --admin_email=\'{1}\'"
                  .format(ee_wp_pass, ee_wp_email))
        try:
            EEShellExec.cmd_exec(self, "php {0} --allow-root core "
                                 .format(EEVariables.ee_wpcli_path)
                                 + "install --url=\'{0}\' --title=\'{0}\' "
                                 "--admin_name=\'{1}\' "
                                 .format(data['www_domain'], ee_wp_user)
                                 + "--admin_password=\'{0}\' "
                                 "--admin_email=\'{1}\'"
                                 .format(ee_wp_pass, ee_wp_email),
                                 log=False)
        except CommandExceutionError as e:
            raise SiteError("setup wordpress tables failed for single site")
    else:
        Log.debug(self, "Creating tables for WordPress multisite")
        Log.debug(self, "php {0} --allow-root "
                  .format(EEVariables.ee_wpcli_path)
                  + "core multisite-install "
                  "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
                  .format(data['www_domain'], ee_wp_user)
                  + "--admin_password= --admin_email=\'{1}\' "
                  "{subdomains}"
                  .format(ee_wp_pass, ee_wp_email,
                          subdomains='--subdomains'
                          if not data['wpsubdir'] else ''))
        try:
            EEShellExec.cmd_exec(self, "php {0} --allow-root "
                                 .format(EEVariables.ee_wpcli_path)
                                 + "core multisite-install "
                                 "--url=\'{0}\' --title=\'{0}\' "
                                 "--admin_name=\'{1}\' "
                                 .format(data['www_domain'], ee_wp_user)
                                 + "--admin_password=\'{0}\' "
                                 "--admin_email=\'{1}\' "
                                 "{subdomains}"
                                 .format(ee_wp_pass, ee_wp_email,
                                         subdomains='--subdomains'
                                         if not data['wpsubdir'] else ''),
                                 log=False)
        except CommandExecutionError as e:
            raise SiteError("setup wordpress tables failed for wp multi site")

    Log.debug(self, "Updating WordPress permalink")
    try:
        EEShellExec.cmd_exec(self, " php {0} --allow-root "
                             .format(EEVariables.ee_wpcli_path)
                             + "rewrite structure "
                             "/%year%/%monthnum%/%day%/%postname%/")
    except CommandExecutionError as e:
        raise SiteError("Update wordpress permalinks failed")

    """Install nginx-helper plugin """
    installwp_plugin(self, 'nginx-helper', data)
    if data['wpfc']:
        plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_fastcgi","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
        setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
    elif data['wpredis']:
        plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_redis","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
        setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)

    """Install Wp Super Cache"""
    if data['wpsc']:
        installwp_plugin(self, 'wp-super-cache', data)

    """Install Redis Cache"""
    if data['wpredis']:
        installwp_plugin(self, 'redis-cache', data)

    """Install W3 Total Cache"""
    if data['w3tc'] or data['wpfc']:
        installwp_plugin(self, 'w3-total-cache', data)

    wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass,
                    wp_email=ee_wp_email)

    return(wp_creds)
Exemple #26
0
def setupwordpress(self, data):
    ee_domain_name = data['site_name']
    ee_site_webroot = data['webroot']
    prompt_wpprefix = self.app.config.get('wordpress', 'prefix')
    ee_wp_user = self.app.config.get('wordpress', 'user')
    ee_wp_pass = self.app.config.get('wordpress', 'password')
    ee_wp_email = self.app.config.get('wordpress', 'email')
    # Random characters
    ee_random = (''.join(random.sample(string.ascii_uppercase +
                 string.ascii_lowercase + string.digits, 15)))
    ee_wp_prefix = ''
    # ee_wp_user = ''
    # ee_wp_pass = ''

    if 'wp-user' in data.keys() and data['wp-user']:
        ee_wp_user = data['wp-user']
    if 'wp-email' in data.keys() and data['wp-email']:
        ee_wp_email = data['wp-email']
    if 'wp-pass' in data.keys() and data['wp-pass']:
        ee_wp_pass = data['wp-pass']

    Log.info(self, "Downloading Wordpress \t\t", end='')
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    try:
        EEShellExec.cmd_exec(self, "wp --allow-root core"
                             " download")
    except CommandExecutionError as e:
        Log.info(self, "[" + Log.ENDC + Log.FAIL + "Fail" + Log.OKBLUE + "]")
        raise SiteError(self, "download wordpress core failed")

    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")

    if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']):
        data = setupdatabase(self, data)
    if prompt_wpprefix == 'True' or prompt_wpprefix == 'true':
        try:
            ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ')
            while not re.match('^[A-Za-z0-9_]*$', ee_wp_prefix):
                Log.warn(self, "table prefix can only "
                         "contain numbers, letters, and underscores")
                ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: '
                                     )
        except EOFError as e:
            Log.debug(self, "{0}".format(e))
            raise SiteError("input table prefix failed")

    if not ee_wp_prefix:
        ee_wp_prefix = 'wp_'

    # Modify wp-config.php & move outside the webroot

    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.debug(self, "Setting up wp-config file")
    if not data['multisite']:
        Log.debug(self, "Generating wp-config for WordPress Single site")
        Log.debug(self, "bash -c \"php {0} --allow-root "
                  .format(EEVariables.ee_wpcli_path)
                  + "core config "
                  + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
                  "--dbhost=\'{3}\' "
                  .format(data['ee_db_name'], ee_wp_prefix,
                          data['ee_db_user'], data['ee_db_host'])
                  + "--dbpass= "******"--extra-php<<PHP \n {1}\nPHP\""
                  .format(data['ee_db_pass'],
                          "\n\ndefine(\'WP_DEBUG\', false);"))
        try:
            EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
                                 .format(EEVariables.ee_wpcli_path)
                                 + " core config "
                                 + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
                                 "--dbuser=\'{2}\' --dbhost=\'{3}\' "
                                 .format(data['ee_db_name'], ee_wp_prefix,
                                         data['ee_db_user'], data['ee_db_host']
                                         )
                                 + "--dbpass=\'{0}\' "
                                   "--extra-php<<PHP \n {1}\nPHP\""
                                   .format(data['ee_db_pass'],
                                           "\n\ndefine(\'WP_DEBUG\', false);"),
                                   log=False
                                 )
        except CommandExecutionError as e:
                raise SiteError("generate wp-config failed for wp single site")
    else:
        Log.debug(self, "Generating wp-config for WordPress multisite")
        Log.debug(self, "bash -c \"php {0} --allow-root "
                  .format(EEVariables.ee_wpcli_path)
                  + "core config "
                  + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
                  .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
                  + "--dbuser=\'{0}\' --dbpass= "******"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
                  .format(data['ee_db_user'], data['ee_db_pass'],
                          "\ndefine(\'WP_ALLOW_MULTISITE\', "
                          "true);",
                          "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
                          " true);",
                          "\n\ndefine(\'WP_DEBUG\', false);"))
        try:
            EEShellExec.cmd_exec(self, "bash -c \"php {0} --allow-root"
                                 .format(EEVariables.ee_wpcli_path)
                                 + " core config "
                                 + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
                                 "--dbhost=\'{2}\' "
                                 .format(data['ee_db_name'], ee_wp_prefix,
                                         data['ee_db_host'])
                                 + "--dbuser=\'{0}\' --dbpass=\'{1}\' "
                                   "--extra-php<<PHP \n {2} {3} {4}\nPHP\""
                                 .format(data['ee_db_user'],
                                         data['ee_db_pass'],
                                         "\ndefine(\'WP_ALLOW_MULTISITE\', "
                                         "true);",
                                         "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
                                         " true);",
                                         "\n\ndefine(\'WP_DEBUG\', false);"),
                                 log=False
                                 )
        except CommandExecutionError as e:
                raise SiteError("generate wp-config failed for wp multi site")

    EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
                       os.path.abspath(os.path.join(os.getcwd(), os.pardir)))

    if not ee_wp_user:
        ee_wp_user = EEVariables.ee_user
        while not ee_wp_user:
            Log.warn(self, "Username can have only alphanumeric"
                     "characters, spaces, underscores, hyphens,"
                     "periods and the @ symbol.")
            try:
                ee_wp_user = input('Enter WordPress username: '******'Enter WordPress email: ')
            except EOFError as e:
                Log.debug(self, "{0}".format(e))
                raise SiteError("input wordpress username failed")

    try:
        while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
                           ee_wp_email):
            Log.info(self, "EMail not Valid in config, "
                     "Please provide valid email id")
            ee_wp_email = input("Enter your email: ")
    except EOFError as e:
        Log.debug(self, "{0}".format(e))
        raise SiteError("input WordPress user email failed")

    Log.debug(self, "Setting up WordPress tables")

    if not data['multisite']:
        Log.debug(self, "Creating tables for WordPress Single site")
        Log.debug(self, "php {0} --allow-root core install "
                  .format(EEVariables.ee_wpcli_path)
                  + "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
                  .format(data['www_domain'], ee_wp_user)
                  + "--admin_password= --admin_email=\'{1}\'"
                  .format(ee_wp_pass, ee_wp_email))
        try:
            EEShellExec.cmd_exec(self, "php {0} --allow-root core "
                                 .format(EEVariables.ee_wpcli_path)
                                 + "install --url=\'{0}\' --title=\'{0}\' "
                                 "--admin_name=\'{1}\' "
                                 .format(data['www_domain'], ee_wp_user)
                                 + "--admin_password=\'{0}\' "
                                 "--admin_email=\'{1}\'"
                                 .format(ee_wp_pass, ee_wp_email),
                                 log=False)
        except CommandExceutionError as e:
            raise SiteError("setup wordpress tables failed for single site")
    else:
        Log.debug(self, "Creating tables for WordPress multisite")
        Log.debug(self, "php {0} --allow-root "
                  .format(EEVariables.ee_wpcli_path)
                  + "core multisite-install "
                  "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
                  .format(data['www_domain'], ee_wp_user)
                  + "--admin_password= --admin_email=\'{1}\' "
                  "{subdomains}"
                  .format(ee_wp_pass, ee_wp_email,
                          subdomains='--subdomains'
                          if not data['wpsubdir'] else ''))
        try:
            EEShellExec.cmd_exec(self, "php {0} --allow-root "
                                 .format(EEVariables.ee_wpcli_path)
                                 + "core multisite-install "
                                 "--url=\'{0}\' --title=\'{0}\' "
                                 "--admin_name=\'{1}\' "
                                 .format(data['www_domain'], ee_wp_user)
                                 + "--admin_password=\'{0}\' "
                                 "--admin_email=\'{1}\' "
                                 "{subdomains}"
                                 .format(ee_wp_pass, ee_wp_email,
                                         subdomains='--subdomains'
                                         if not data['wpsubdir'] else ''),
                                 log=False)
        except CommandExecutionError as e:
            raise SiteError("setup wordpress tables failed for wp multi site")

    Log.debug(self, "Updating WordPress permalink")
    try:
        EEShellExec.cmd_exec(self, " php {0} --allow-root "
                             .format(EEVariables.ee_wpcli_path)
                             + "rewrite structure "
                             "/%year%/%monthnum%/%day%/%postname%/")
    except CommandExecutionError as e:
        raise SiteError("Update wordpress permalinks failed")

    """Install nginx-helper plugin """
    installwp_plugin(self, 'nginx-helper', data)
    if data['wpfc']:
        plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_fastcgi","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
        setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)
    elif data['wpredis']:
        plugin_data = '{"log_level":"INFO","log_filesize":5,"enable_purge":1,"enable_map":0,"enable_log":0,"enable_stamp":0,"purge_homepage_on_new":1,"purge_homepage_on_edit":1,"purge_homepage_on_del":1,"purge_archive_on_new":1,"purge_archive_on_edit":0,"purge_archive_on_del":0,"purge_archive_on_new_comment":0,"purge_archive_on_deleted_comment":0,"purge_page_on_mod":1,"purge_page_on_new_comment":1,"purge_page_on_deleted_comment":1,"cache_method":"enable_redis","purge_method":"get_request","redis_hostname":"127.0.0.1","redis_port":"6379","redis_prefix":"nginx-cache:"}'
        setupwp_plugin(self, 'nginx-helper', 'rt_wp_nginx_helper_options', plugin_data, data)

    """Install Wp Super Cache"""
    if data['wpsc']:
        installwp_plugin(self, 'wp-super-cache', data)

    """Install Redis Cache"""
    if data['wpredis']:
        installwp_plugin(self, 'redis-cache', data)

    """Install W3 Total Cache"""
    if data['w3tc'] or data['wpfc']:
        installwp_plugin(self, 'w3-total-cache', data)

    wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass,
                    wp_email=ee_wp_email)

    return(wp_creds)
Exemple #27
0
def setupwordpress(self, data):
    ee_domain_name = data['site_name']
    ee_site_webroot = data['webroot']
    prompt_wpprefix = self.app.config.get('wordpress', 'prefix')
    ee_wp_user = self.app.config.get('wordpress', 'user')
    ee_wp_pass = self.app.config.get('wordpress', 'password')
    ee_wp_email = self.app.config.get('wordpress', 'email')
    # Random characters
    ee_random = (''.join(random.sample(string.ascii_uppercase +
                 string.ascii_lowercase + string.digits, 15)))
    ee_wp_prefix = ''
    # ee_wp_user = ''
    # ee_wp_pass = ''

    Log.info(self, "Downloading Wordpress \t\t", end='')
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    EEShellExec.cmd_exec(self, "wp --allow-root core download")
    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")

    if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']):
        data = setupdatabase(self, data)
    if prompt_wpprefix == 'True' or prompt_wpprefix == 'true':
        try:
            ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ')
            while not re.match('^[A-Za-z0-9_]*$', ee_wp_prefix):
                Log.warn(self, "table prefix can only "
                         "contain numbers, letters, and underscores")
                ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: '
                                     )
        except EOFError as e:
            Log.debug(self, "{0}".format(e))
            Log.error(self, "Unable to input table prefix")

    if not ee_wp_prefix:
        ee_wp_prefix = 'wp_'

    # Modify wp-config.php & move outside the webroot

    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.debug(self, "Setting up wp-config file")
    if not data['multisite']:
        Log.debug(self, "Generating wp-config for WordPress Single site")
        Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
                  + "core config "
                  + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbuser=\'{2}\' "
                  "--dbhost=\'{3}\' "
                  .format(data['ee_db_name'], ee_wp_prefix,
                          data['ee_db_user'], data['ee_db_host'])
                  + "--dbpass= "******"--extra-php<<PHP \n {1}\nPHP\""
                  .format(data['ee_db_pass'],
                          "\n\ndefine(\'WP_DEBUG\', false);"))
        EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
                             + "core config "
                             + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
                             "--dbuser=\'{2}\' --dbhost=\'{3}\' "
                             .format(data['ee_db_name'], ee_wp_prefix,
                                     data['ee_db_user'], data['ee_db_host'])
                             + "--dbpass=\'{0}\' "
                               "--extra-php<<PHP \n {1}\nPHP\""
                               .format(data['ee_db_pass'],
                                       "\n\ndefine(\'WP_DEBUG\', false);"),
                               log=False
                             ) or Log.error(self,
                                            "Unable to Generate "
                                            "wp-config")
    else:
        Log.debug(self, "Generating wp-config for WordPress multisite")
        Log.debug(self, "bash -c \"php /usr/bin/wp --allow-root "
                  + "core config "
                  + "--dbname=\'{0}\' --dbprefix=\'{1}\' --dbhost=\'{2}\' "
                  .format(data['ee_db_name'], ee_wp_prefix, data['ee_db_host'])
                  + "--dbuser=\'{0}\' --dbpass= "******"--extra-php<<PHP \n {2} {3} {4}\nPHP\""
                  .format(data['ee_db_user'], data['ee_db_pass'],
                          "\ndefine(\'WP_ALLOW_MULTISITE\', "
                          "true);",
                          "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
                          " true);",
                          "\n\ndefine(\'WP_DEBUG\', false);"))
        EEShellExec.cmd_exec(self, "bash -c \"php /usr/bin/wp --allow-root "
                             + "core config "
                             + "--dbname=\'{0}\' --dbprefix=\'{1}\' "
                             "--dbhost=\'{2}\' "
                             .format(data['ee_db_name'], ee_wp_prefix,
                                     data['ee_db_host'])
                             + "--dbuser=\'{0}\' --dbpass=\'{1}\' "
                               "--extra-php<<PHP \n {2} {3} {4}\nPHP\""
                             .format(data['ee_db_user'], data['ee_db_pass'],
                                     "\ndefine(\'WP_ALLOW_MULTISITE\', "
                                     "true);",
                                     "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
                                     " true);",
                                     "\n\ndefine(\'WP_DEBUG\', false);"),
                             log=False
                             ) or Log.error(self,
                                            "Unable to Generate "
                                            "wp-config")
    EEFileUtils.mvfile(self, os.getcwd()+'/wp-config.php',
                       os.path.abspath(os.path.join(os.getcwd(), os.pardir)))

    if not ee_wp_user:
        ee_wp_user = EEVariables.ee_user
        while not ee_wp_user:
            Log.warn(self, "Username can have only alphanumeric"
                     "characters, spaces, underscores, hyphens,"
                     "periods and the @ symbol.")
            try:
                ee_wp_user = input('Enter WordPress username: '******'Enter WordPress email: ')
            except EOFError as e:
                Log.debug(self, "{0}".format(e))
                Log.error(self, "Unable to input WordPress user email")

    try:
        while not re.match(r"^[A-Za-z0-9\.\+_-]+@[A-Za-z0-9\._-]+\.[a-zA-Z]*$",
                           ee_wp_email):
            Log.info(self, "EMail not Valid in config, "
                     "Please provide valid email id")
            ee_wp_email = input("Enter your email: ")
    except EOFError as e:
        Log.debug(self, "{0}".format(e))
        Log.error(self, "Unable to input WordPress user email")

    Log.debug(self, "Setting up WordPress tables")

    if not data['multisite']:
        Log.debug(self, "Creating tables for WordPress Single site")
        Log.debug(self, "php /usr/bin/wp --allow-root core install "
                  "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
                  .format(data['www_domain'], ee_wp_user)
                  + "--admin_password= --admin_email=\'{1}\'"
                  .format(ee_wp_pass, ee_wp_email))
        EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root core install "
                             "--url=\'{0}\' --title=\'{0}\' "
                             "--admin_name=\'{1}\' "
                             .format(data['www_domain'], ee_wp_user)
                             + "--admin_password=\'{0}\' --admin_email=\'{1}\'"
                             .format(ee_wp_pass, ee_wp_email),
                             errormsg="Unable to setup WordPress Tables",
                             log=False) or Log.error(self,
                                                     "Unable to setup "
                                                     "WordPress Tables")
    else:
        Log.debug(self, "Creating tables for WordPress multisite")
        Log.debug(self, "php /usr/bin/wp --allow-root "
                  "core multisite-install "
                  "--url=\'{0}\' --title=\'{0}\' --admin_name=\'{1}\' "
                  .format(data['www_domain'], ee_wp_user)
                  + "--admin_password= --admin_email=\'{1}\' "
                  "{subdomains}"
                  .format(ee_wp_pass, ee_wp_email,
                          subdomains='--subdomains'
                          if not data['wpsubdir'] else ''))
        EEShellExec.cmd_exec(self, "php /usr/bin/wp --allow-root "
                             "core multisite-install "
                             "--url=\'{0}\' --title=\'{0}\' "
                             "--admin_name=\'{1}\' "
                             .format(data['www_domain'], ee_wp_user)
                             + "--admin_password=\'{0}\' "
                             "--admin_email=\'{1}\' "
                             "{subdomains}"
                             .format(ee_wp_pass, ee_wp_email,
                                     subdomains='--subdomains'
                                     if not data['wpsubdir'] else ''),
                             errormsg="Unable to setup WordPress Tables",
                             log=False) or Log.error(self,
                                                     "Unable to setup "
                                                     "WordPress Tables")

    Log.debug(self, "Updating WordPress permalink")
    EEShellExec.cmd_exec(self, " php /usr/bin/wp --allow-root "
                         "rewrite structure "
                         "/%year%/%monthnum%/%day%/%postname%/",
                         errormsg="Unable to Update WordPress permalink")

    """Install nginx-helper plugin """
    installwp_plugin(self, 'nginx-helper', data)

    """Install Wp Super Cache"""
    if data['wpsc']:
        installwp_plugin(self, 'wp-super-cache', data)

    """Install W3 Total Cache"""
    if data['w3tc'] or data['wpfc']:
        installwp_plugin(self, 'w3-total-cache', data)

    wp_creds = dict(wp_user=ee_wp_user, wp_pass=ee_wp_pass,
                    wp_email=ee_wp_email)

    return(wp_creds)
def setupwordpress(self, data):
    ee_domain_name = data['site_name']
    ee_site_webroot = data['webroot']
    prompt_wpprefix = self.app.config.get('wordpress', 'prefix')
    ee_wp_user = self.app.config.get('wordpress', 'user')
    ee_wp_pass = self.app.config.get('wordpress', 'password')
    ee_wp_email = self.app.config.get('wordpress', 'email')
    # Random characters
    ee_random = (''.join(
        random.sample(
            string.ascii_uppercase + string.ascii_lowercase + string.digits,
            15)))
    ee_wp_prefix = ''
    # ee_wp_user = ''
    # ee_wp_pass = ''

    Log.info(self, "Downloading Wordpress \t\t", end='')
    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    EEShellExec.cmd_exec(self, "wp --allow-root core download")
    Log.info(self, "[" + Log.ENDC + "Done" + Log.OKBLUE + "]")

    if not (data['ee_db_name'] and data['ee_db_user'] and data['ee_db_pass']):
        data = setupdatabase(self, data)
    if prompt_wpprefix == 'True' or prompt_wpprefix == 'true':
        try:
            ee_wp_prefix = input('Enter the WordPress table prefix [wp_]: ')
            while not re.match('^[A-Za-z0-9_]*$', ee_wp_prefix):
                Log.warn(
                    self, "table prefix can only "
                    "contain numbers, letters, and underscores")
                ee_wp_prefix = input(
                    'Enter the WordPress table prefix [wp_]: ')
        except EOFError as e:
            Log.debug(self, "{0}".format(e))
            Log.error(self, "Unable to input table prefix")

    if not ee_wp_prefix:
        ee_wp_prefix = 'wp_'

    # Modify wp-config.php & move outside the webroot

    EEFileUtils.chdir(self, '{0}/htdocs/'.format(ee_site_webroot))
    Log.debug(self, "Setting up wp-config file")
    if not data['multisite']:
        Log.debug(self, "Generating wp-config for WordPress Single site")
        Log.debug(
            self, "bash -c \"php /usr/bin/wp --allow-root " + "core config " +
            "--dbname={0} --dbprefix={1} --dbuser={2} --dbhost={3} ".format(
                data['ee_db_name'], ee_wp_prefix, data['ee_db_user'],
                data['ee_db_host']) + "--dbpass= "******"--extra-php<<PHP \n {1}\nPHP\"".format(
                data['ee_db_pass'], "\n\ndefine(\'WP_DEBUG\', false);"))
        EEShellExec.cmd_exec(
            self,
            "bash -c \"php /usr/bin/wp --allow-root " + "core config " +
            "--dbname={0} --dbprefix={1} --dbuser={2} --dbhost={3} ".format(
                data['ee_db_name'], ee_wp_prefix, data['ee_db_user'],
                data['ee_db_host']) + "--dbpass={0} "
            "--extra-php<<PHP \n {1}\nPHP\"".format(
                data['ee_db_pass'], "\n\ndefine(\'WP_DEBUG\', false);"),
            log=False)
    else:
        Log.debug(self, "Generating wp-config for WordPress multisite")
        Log.debug(
            self, "bash -c \"php /usr/bin/wp --allow-root " + "core config " +
            "--dbname={0} --dbprefix={1} --dbhost={2} ".format(
                data['ee_db_name'], ee_wp_prefix, data['ee_db_host']) +
            "--dbuser={0} --dbpass= "******"--extra-php<<PHP \n {2} {3} {4}\nPHP\"".format(
                data['ee_db_user'], data['ee_db_pass'],
                "\ndefine(\'WP_ALLOW_MULTISITE\', "
                "true);", "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
                " true);", "\n\ndefine(\'WP_DEBUG\', false);"))
        EEShellExec.cmd_exec(
            self,
            "bash -c \"php /usr/bin/wp --allow-root " + "core config " +
            "--dbname={0} --dbprefix={1} --dbhost={2} ".format(
                data['ee_db_name'], ee_wp_prefix, data['ee_db_host']) +
            "--dbuser={0} --dbpass={1} "
            "--extra-php<<PHP \n {2} {3} {4}\nPHP\"".format(
                data['ee_db_user'], data['ee_db_pass'],
                "\ndefine(\'WP_ALLOW_MULTISITE\', "
                "true);", "\ndefine(\'WPMU_ACCEL_REDIRECT\',"
                " true);", "\n\ndefine(\'WP_DEBUG\', false);"),
            log=False)
    EEFileUtils.mvfile(self,
                       os.getcwd() + '/wp-config.php',
                       os.path.abspath(os.path.join(os.getcwd(), os.pardir)))

    if not ee_wp_user:
        ee_wp_user = EEVariables.ee_user
        while not ee_wp_user:
            Log.warn(
                self, "Username can have only alphanumeric"
                "characters, spaces, underscores, hyphens,"
                "periods and the @ symbol.")
            try:
                ee_wp_user = input('Enter WordPress username: '******'Enter WordPress email: ')
            except EOFError as e:
                Log.debug(self, "{0}".format(e))
                Log.error(self, "Unable to input WordPress user email")

    Log.debug(self, "Setting up WordPress tables")

    if not data['multisite']:
        Log.debug(self, "Creating tables for WordPress Single site")
        Log.debug(
            self, "php /usr/bin/wp --allow-root core install "
            "--url={0} --title={0} --admin_name={1} ".format(
                data['www_domain'], ee_wp_user) +
            "--admin_password= --admin_email={1}".format(
                ee_wp_pass, ee_wp_email))
        EEShellExec.cmd_exec(self,
                             "php /usr/bin/wp --allow-root core install "
                             "--url={0} --title={0} --admin_name={1} ".format(
                                 data['www_domain'], ee_wp_user) +
                             "--admin_password={0} --admin_email={1}".format(
                                 ee_wp_pass, ee_wp_email),
                             errormsg="Unable to setup WordPress Tables",
                             log=False)
    else:
        Log.debug(self, "Creating tables for WordPress multisite")
        Log.debug(
            self, "php /usr/bin/wp --allow-root "
            "core multisite-install "
            "--url={0} --title={0} --admin_name={1} ".format(
                data['www_domain'], ee_wp_user) +
            "--admin_password= --admin_email={1} "
            "{subdomains}".format(
                ee_wp_pass,
                ee_wp_email,
                subdomains='--subdomains' if not data['wpsubdir'] else ''))
        EEShellExec.cmd_exec(
            self,
            "php /usr/bin/wp --allow-root "
            "core multisite-install "
            "--url={0} --title={0} --admin_name={1} ".format(
                data['www_domain'], ee_wp_user) +
            "--admin_password={0} --admin_email={1} "
            "{subdomains}".format(
                ee_wp_pass,
                ee_wp_email,
                subdomains='--subdomains' if not data['wpsubdir'] else ''),
            errormsg="Unable to setup WordPress Tables")

    Log.debug(self, "Updating WordPress permalink")
    EEShellExec.cmd_exec(self, " php /usr/bin/wp --allow-root "
                         "rewrite structure "
                         "/%year%/%monthnum%/%day%/%postname%/",
                         errormsg="Unable to Update WordPress permalink")
    """Install nginx-helper plugin """
    installwp_plugin(self, 'nginx-helper', data)
    """Install Wp Super Cache"""
    if data['wpsc']:
        installwp_plugin(self, 'wp-super-cache', data)
    """Install W3 Total Cache"""
    if data['w3tc'] or data['wpfc']:
        installwp_plugin(self, 'w3-total-cache', data)

    wp_creds = dict(wp_user=ee_wp_user,
                    wp_pass=ee_wp_pass,
                    wp_email=ee_wp_email)

    return (wp_creds)