Пример #1
0
 def siteurlhttps(self, domain):
     wo_site_webroot = ('/var/www/{0}'.format(domain))
     WOFileUtils.chdir(self, '{0}/htdocs/'.format(wo_site_webroot))
     if WOShellExec.cmd_exec(
             self, "{0} --allow-root core is-installed".format(
                 WOVar.wo_wpcli_path)):
         wo_siteurl = (WOShellExec.cmd_exec_stdout(
             self, "{0} option get siteurl ".format(WOVar.wo_wpcli_path) +
             "--allow-root --quiet"))
         test_url = re.split(":", wo_siteurl)
         if not (test_url[0] == 'https'):
             Log.wait(self, "Updating site url with https")
             try:
                 WOShellExec.cmd_exec(
                     self, "{0} option update siteurl "
                     "\'https://{1}\' --allow-root".format(
                         WOVar.wo_wpcli_path, domain))
                 WOShellExec.cmd_exec(
                     self, "{0} option update home "
                     "\'https://{1}\' --allow-root".format(
                         WOVar.wo_wpcli_path, domain))
                 WOShellExec.cmd_exec(
                     self, "{0} search-replace \'http://{1}\'"
                     "\'https://{1}\' --skip-columns=guid "
                     "--skip-tables=wp_users".format(
                         WOVar.wo_wpcli_path, domain))
             except Exception as e:
                 Log.debug(self, str(e))
                 Log.failed(self, "Updating site url with https")
             else:
                 Log.valide(self, "Updating site url with https")
Пример #2
0
    def cd(self):
        pargs = self.app.pargs
        if not pargs.site_name:
            try:
                while not pargs.site_name:
                    pargs.site_name = (input('Enter site name : ').strip())
            except IOError as e:
                Log.debug(self, str(e))
                Log.error(self, 'Unable to read input, please try again')

        pargs.site_name = pargs.site_name.strip()
        wo_domain = WODomain.validate(self, pargs.site_name)

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

        wo_site_webroot = getSiteInfo(self, wo_domain).site_path
        if os.path.isdir(wo_site_webroot):
            WOFileUtils.chdir(self, wo_site_webroot)

        try:
            subprocess.call(['/bin/bash'])
        except OSError as e:
            Log.debug(self, "{0}{1}".format(e.errno, e.strerror))
        else:
            Log.error(self, "unable to change directory")
Пример #3
0
 def check_acme(self):
     """
     Check if acme.sh is properly installed,
     and install it if required
     """
     if not os.path.exists('/etc/letsencrypt/acme.sh'):
         if os.path.exists('/opt/acme.sh'):
             WOFileUtils.rm(self, '/opt/acme.sh')
         WOGit.clone(
             self, 'https://github.com/Neilpang/acme.sh.git',
             '/opt/acme.sh', branch='master')
         WOFileUtils.mkdir(self, '/etc/letsencrypt/config')
         WOFileUtils.mkdir(self, '/etc/letsencrypt/renewal')
         WOFileUtils.mkdir(self, '/etc/letsencrypt/live')
         try:
             WOFileUtils.chdir(self, '/opt/acme.sh')
             WOShellExec.cmd_exec(
                 self, './acme.sh --install --home /etc/letsencrypt'
                 '--config-home /etc/letsencrypt/config'
                 '--cert-home /etc/letsencrypt/renewal'
             )
             WOShellExec.cmd_exec(
                 self, "{0} --upgrade --auto-upgrade"
                 .format(WOAcme.wo_acme_exec)
             )
         except CommandExecutionError as e:
             Log.debug(self, str(e))
             Log.error(self, "acme.sh installation failed")
     if not os.path.exists('/etc/letsencrypt/acme.sh'):
         Log.error(self, 'acme.sh ')