コード例 #1
0
ファイル: site_convert.py プロジェクト: pylanglois/uwsa
    def to_dev(self, args):
        completed = False
        args.remove("todev")

        site_name = self.ask_site_name(self.get_next_arg(args))
        if not self.is_conf_exists(site_name):
            completed = True
            print t("Sorry, the site '%s' does not exists.") % site_name
            return completed
        self.load(site_name)

        site_path, root_path, log_path, upload_tmp_path = self.generate_dir()
        errors = False

        if self.conf.get("mysql", "enabled"):
            schema = self.conf.get("mysql", "schema")
            # user = self.conf.get('mysql', 'user')
            # password = self.conf.get('mysql', 'pass')
            if inputs.get_input_yesno(t("The schema '%s' will be converted. Continue?") % schema):
                filename = "/tmp/site_convert_todev_%s" % uuid.uuid4()
                if not (self.dump_bd(filename) and self.schema_todev(filename) and self.restore_bd(filename)):
                    L.error(t("Fail to convert schema"))
                    errors = True
                files.rm(filename)

        if errors and not inputs.get_input_yesno(t("There was some errors. Continue?")):
            completed = False
            return completed

        if inputs.get_input_yesno(t("The files under %s will be converted. Continue??") % root_path):
            site_name = self.conf.get("main", "site_name")
            site_dev_name = self.conf.get("main", "site_dev_name")
            site_name_escape = site_name.replace(".", "\.")
            file_list = self.get_file_list(root_path)
            for f in file_list:
                print t("Converting file %s") % f
                files.re_replace_in(f, site_name_escape, site_dev_name)
                files.re_replace_in(f, "(dev\.)*%s" % site_name_escape, site_dev_name)

        robot = root_path + "/robots.txt"
        prodrobot = root_path + "/robots.txt.prod"

        if files.exists(robot):
            self.show_file(t("------- ROBOTS.TXT --------"), robot)
        if files.exists(prodrobot):
            self.show_file(t("------- ROBOTS.TXT.PROD --------"), prodrobot)

        if files.exists(robot) and inputs.get_input_yesno(
            t("Do you want to backup current robots.txt to robots.txt.prod?")
        ):
            if not files.exists(prodrobot) or (
                files.exists(prodrobot) and inputs.get_input_noyes(t("The robots.txt.prod exists. Overwrite?"))
            ):
                files.cp(robot, prodrobot)
        if inputs.get_input_yesno(t("Do you want create a dev robots.txt that disallow all?")):
            with open(files.get_rel_path("data/dev.robots.txt")) as devbot_tpl:
                files.create(robot, devbot_tpl.read())

        completed = True
        return completed
コード例 #2
0
ファイル: install_uwsa.py プロジェクト: pylanglois/uwsa
    def fix_uwsa_conf(self, element):

        with open(files.get_rel_path("data/uwsa.conf.tpl")) as f:
            files.create(element["name"], f.read())

        core.CONFIG.load(element["name"])
        core.CONFIG.save_to_file(element["name"])
コード例 #3
0
ファイル: site.py プロジェクト: pylanglois/uwsa
    def fix_cron_acl(self):
        unix_group = self.conf.get('access','unix_group')
        ldap_group = self.conf.get('access','ldap_group')

        if unix_group and CONF_MAP('unix','enabled'):
            unix_acl = self.generate_acl(unix_group)
            cron_fullpath = "/etc/cron.acl/%s" % self.get_safe_name(unix_group)
            files.create(cron_fullpath, unix_acl)
            files.chmod(cron_fullpath, u='rx',g='rx',o='rx')

        if ldap_group and CONF_MAP('ldap','enabled'):
            ldap_acl = self.generate_acl(ldap_group)
            cron_fullpath = "/etc/cron.acl/%s" % self.get_safe_name(ldap_group)
            files.create(cron_fullpath, ldap_acl)
            files.chmod(cron_fullpath, u='rx',g='rx',o='rx')
コード例 #4
0
 def fix_ses_open(self, element):
     with open(files.get_rel_path("data/pam_script_ses_open.py")) as f:
         content = f.read()
         if not files.contains(element['name'], content):
             files.create(element['name'], content)
コード例 #5
0
ファイル: site.py プロジェクト: pylanglois/uwsa
 def fix_auto_mount(self):
     safe_site_name = self.get_safe_name(self.conf.get('main','site_name'))
     auto_mount = self.generate_auto_mount()
     auto_mount_filename = CONF_MAP('libpam_script','auto_mount_dir') + "/%s" % safe_site_name
     files.create(auto_mount_filename, auto_mount)
     files.chmod(auto_mount_filename, u='rx',g='rx',o='')
コード例 #6
0
ファイル: site.py プロジェクト: pylanglois/uwsa
 def fix_vhost(self):
     safe_site_name = self.get_safe_name(self.conf.get('main','site_name'))
     vhost = self.generate_virtualhost()
     vhost_filename = CONF_MAP('site','vhost_path') + "/%s" % safe_site_name
     files.create(vhost_filename, vhost)
コード例 #7
0
ファイル: install_acl.py プロジェクト: pylanglois/uwsa
 def fix_perm_dev_team(self, element):
     if not files.contains(element['name'], self.cron_acl_dev_team):
         files.create(element['name'], self.cron_acl_dev_team)
     files.chmod(element['name'], u='rx',g='rx',o='rx')
コード例 #8
0
ファイル: install_acl.py プロジェクト: pylanglois/uwsa
 def fix_perm_cron(self, element):
     if not files.contains(element['name'], self.cron_acl_sudo):
         files.create(element['name'], self.cron_acl_sudo)
     files.chmod(element['name'], u='rx',g='rx',o='rx')
コード例 #9
0
ファイル: install_centrify.py プロジェクト: pylanglois/uwsa
 def fix_user_allow(self, element):
     if not files.exists(element['name']):
         files.create(element['name'], '')
コード例 #10
0
ファイル: install_uwsa.py プロジェクト: pylanglois/uwsa
 def fix_logrotate(self, element):
     logrotate_template = Template(open(files.get_rel_path("data/logrotate_uwsa.tpl")).read())
     files.create(element["name"], logrotate_template.safe_substitute())
コード例 #11
0
ファイル: install_apache.py プロジェクト: pylanglois/uwsa
 def fix_vh_default_ssl(self, element):
     with open(files.get_rel_path("data/virtualhost_def_ssl.tpl")) as index:
         files.create(element['name'], index.read())
     self.graceful(element['name'])
コード例 #12
0
ファイル: install_apache.py プロジェクト: pylanglois/uwsa
 def fix_default_index(self, element):
     with open(files.get_rel_path("data/default.html.tpl")) as index:
         files.create(element['name'], index.read())