コード例 #1
0
            if not self.ask_create_name(self.get_next_arg(args)):
                #self.ask_alias_name()
                self.ask_dev_name()
                self.update_client_info()
                self.ask_create_access()
                self.ask_create_mysql(mandatory=True)
                self.ask_allow_override(default='All')
                self.conf.mod('php','enabled', True)
                self.conf.mod('php','php_engine','on')
                mysql_enabled = self.conf.get('mysql','schema') is not None
                self.conf.mod('mysql','enabled', mysql_enabled)
                self.conf.mod('wordpress','enabled', True)
                self.conf.mod('wikimedia','enabled', False)
                self.conf.mod('typo3','enabled', False)
                self.save()
                self.fix_config(overwrite=True)
                try:
                    if inputs.get_input_yesno(t("Do you want to send configuration of %(name)s to %(mail)s?") %
                                                {   'name': self.conf.get('main','site_name'), 
                                                    'mail': CONF_MAP('mail','admin_mail'),
                                                }):
                        self.send_status_mail()
                except Exception:
                    L.exception(t("Problem sending mail in %s") % __file__)
                print self.gen_status_msg()
                completed = True

        return completed

cmanager.get(SiteCommand.NAME).get(SiteCreateCommand.NAME).register(SiteCreateWordpressCommand.NAME, SiteCreateWordpressCommand())
コード例 #2
0
ファイル: install_mysql.py プロジェクト: pylanglois/uwsa
    def fix_mysql(self, element):
        self.install_mysql(element)
        self.move_mysql(element)

    def install_mysql(self, element):
        cmd = "bash -c 'DEBIAN_FRONTEND=noninteractive apt-get install -y %s'" % self.packages
        completed = core.exec_cmd_list([cmd])
        if not completed:
            raise Exception(t("Error in installation!"), element['name'])

    def move_mysql(self, element):
        if not files.contains('/etc/apparmor.d/usr.sbin.mysqld', '/data/mysql/'):
            files.replace_in('/etc/apparmor.d/usr.sbin.mysqld',
                                '/var/lib/mysql/',
                                '/data/mysql/')
        if not files.realpath('/var/lib/mysql/') == '/data/mysql':
            cmd_list = [
                "/etc/init.d/mysql stop",
                "mv /var/lib/mysql/ /data/",
                "ln -s /data/mysql /var/lib/mysql",
                "chown -h mysql:mysql /var/lib/mysql",
                "service apparmor reload",
                "/etc/init.d/mysql start",
            ]
            completed, pinfo = core.exec_cmd_list(cmd_list)
            if not completed:
                raise Exception(t("Error in installation!"), element['name'])

cmanager.get(InstallCommand.NAME).register(InstallMySQLCommand.NAME, InstallMySQLCommand())
コード例 #3
0
ファイル: site_create_html.py プロジェクト: pylanglois/uwsa
        completed = SiteCreateCommand.do(self,args)
        if not completed:

            if not self.ask_create_name(self.get_next_arg(args)):
                #self.ask_alias_name()
                self.ask_dev_name()
                self.update_client_info()
                self.ask_create_access()
                self.ask_allow_override()
                self.conf.mod('mysql','enabled', False)
                self.conf.mod('php','enabled', False)
                self.conf.mod('wordpress','enabled', False)
                self.conf.mod('wikimedia','enabled', False)
                self.conf.mod('typo3','enabled', False)
                self.save()
                self.fix_config(overwrite=True)
                try:
                    if inputs.get_input_yesno(t("Do you want to send configuration of %(name)s to %(mail)s?") %
                                                {   'name': self.conf.get('main','site_name'), 
                                                    'mail': CONF_MAP('mail','admin_mail'),
                                                }):
                        self.send_status_mail()
                except Exception:
                    L.exception(t("Problem sending mail in %s") % __file__)
                print self.gen_status_msg()
                completed = True
    
        return completed

cmanager.get(SiteCommand.NAME).get(SiteCreateCommand.NAME).register(SiteCreateHTMLCommand.NAME, SiteCreateHTMLCommand())
コード例 #4
0
    def fix_common_session(self, element):
        if not files.contains(element['name'], '\nsession\trequired\tpam_script.so\trunas=root\n'):
            files.replace_in(element['name'],
                            'session\trequired\tpam_unix.so',
                            'session\trequired\tpam_script.so\trunas=root\nsession\trequired\tpam_unix.so\n')

    def check_ses_open(self, element):
        is_ok = True
        with open(files.get_rel_path("data/pam_script_ses_open.py")) as f:
            is_ok &= files.contains(element['name'], f.read())
        return is_ok

    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)

    def check_ses_close(self, element):
        is_ok = True
        is_ok &= files.exists(element['name'])
        return is_ok

    def fix_ses_close(self, element):

        if not files.exists(element['name']):
            files.append(element['name'], "#! /bin/sh")
        

cmanager.get(InstallCommand.NAME).register(InstallLibPAMScriptCommand.NAME, InstallLibPAMScriptCommand())
コード例 #5
0
ファイル: install_base.py プロジェクト: pylanglois/uwsa
        self.add_prerequisite(InstallPHPCommand.NAME, obj=InstallPHPCommand())
        self.add_prerequisite(InstallApacheCommand.NAME, obj=InstallApacheCommand())
        self.add_prerequisite(InstallMySQLCommand.NAME, obj=InstallMySQLCommand())
        self.add_prerequisite(InstallAutoMySQLBackupCommand.NAME, obj=InstallAutoMySQLBackupCommand())
        self.add_prerequisite(InstallUFWCommand.NAME, obj=InstallUFWCommand())
        self.add_prerequisite(InstallSSHCommand.NAME, obj=InstallSSHCommand())
        self.add_prerequisite(InstallMuninNodeCommand.NAME, obj=InstallMuninNodeCommand())
        self.add_prerequisite(InstallACLCommand.NAME, obj=InstallACLCommand())
        self.add_prerequisite(InstallAWStatsCommand.NAME, obj=InstallAWStatsCommand())
        self.add_prerequisite(InstallLibPAMScriptCommand.NAME, obj=InstallLibPAMScriptCommand())
        self.add_prerequisite(InstallGrubGFXCommand.NAME, obj=InstallGrubGFXCommand())
        self.add_prerequisite(InstallCentrifyCommand.NAME, obj=InstallCentrifyCommand())

    def init_help(self):
        help = InstallCommand.init_help(self)
        help['command_detail'] = t("%s\n\t"
                                    "This command will install the almost perfect uwsa server." % 
                                    help['command_detail'])

    def do(self, args=[]):
        completed = InstallCommand.do(self,args)
        if 'check' not in args and 'fix' not in args:
            MySQLCommand().do(['reset_root_pass'])
            admin_mail = inputs.get_input_string(t("What is the admin mail?"), CONF_MAP('mail','admin_mail'))
            smtp_server = inputs.get_input_string(t("What is the smtp server to use?"), CONF_MAP('mail','smtp_server'))
            CONFIG.mod('mail','admin_mail', admin_mail)
            CONFIG.mod('mail','smtp_server', smtp_server)
            CONFIG.save()

cmanager.get(InstallCommand.NAME).register(InstallBaseCommand.NAME, InstallBaseCommand())
コード例 #6
0
ファイル: install_centrify.py プロジェクト: pylanglois/uwsa
        if not files.contains(element['name'], '"domain admins"'):
            files.append(element['name'], '\n"domain admins"')

        if CONFIG.is_set('site','ldap_dev_team'):
            ldap_dev_team_val = '\n%s' % CONF_MAP('site','ldap_dev_team')
            if not files.contains(element['name'], ldap_dev_team_val):
                files.append(element['name'], ldap_dev_team_val)


    def check_sudoers(self, element):
        is_ok = True
        is_ok &= files.contains(element['name'], '%domain\ admins ALL=(ALL) ALL')
        return is_ok

    def fix_sudoers(self, element):
        if not files.contains(element['name'], '%domain\ admins ALL=(ALL) ALL'):
            files.append(element['name'], '%domain\ admins ALL=(ALL) ALL')
        files.chmod(element['name'], **element['perm'])

    def check_perm_cron(self, element):
        is_ok = False
        is_ok = files.contains(element['name'], self.cron_acl_domainadmins)
        return is_ok

    def fix_perm_cron(self, element):
        if not files.contains(element['name'], self.cron_acl_domainadmins):
            files.create(element['name'], self.cron_acl_domainadmins)
        files.chmod(element['name'], u='rx',g='rx',o='rx')

cmanager.get(InstallCommand.NAME).register(InstallCentrifyCommand.NAME, InstallCentrifyCommand())
コード例 #7
0
ファイル: site_convert.py プロジェクト: pylanglois/uwsa
    def test(self, args):
        """
        define('DB_NAME', '1');
        define('DB_USER', '2');
        define('DB_PASSWORD', '3');
        define('DB_HOST', '4');
        """
        filename = "/tmp/wp-config.php"
        pattern = "define\(\s*?['\"]DB_NAME['\"].*;"
        target = "define('%s', '%s');" % ("DB_NAME", "UWSA_SCHEMA_NAME")
        files.re_replace_in(filename, pattern, target)

    def get_file_list(self, path):
        allowed_type = ["application/javascript", "application/x-httpd-php", "text/"]
        file_list = []
        local_list = files.ls(path)
        for f in local_list:
            if files.is_dir(f):
                file_list += self.get_file_list("%s/*" % f)
            else:
                mt = str(mimetypes.guess_type(f)[0])
                for allowed in allowed_type:
                    if mt.startswith(allowed):
                        file_list.append(f)
                        break

        return file_list


cmanager.get(SiteCommand.NAME).register(SiteConvert.NAME, SiteConvert())
コード例 #8
0
    def __init__(self):
        InstallCommand.__init__(self)
        self.packages = "automysqlbackup"
        self.add_package(self.packages)
        self.add_file('/etc/default/automysqlbackup', 
                        ck_func=self.check_backup, 
                        fix_func=self.fix_backup)

    def init_help(self):
        help = InstallCommand.init_help(self)
        help['command_detail'] = t("%s\n\t"
                                    "The folder /var/lib/automysqlbackup will be moved to /data/automysqlbackup\n\t" % 
                                    help['command_detail'])
        return help

    def check_backup(self, element):
        is_ok = True

        is_ok &= files.contains(element['name'], 'BACKUPDIR="/data/automysqlbackup"')

        return is_ok

    def fix_backup(self, element):

        files.replace_in(element['name'],
                        'BACKUPDIR="/var/lib/automysqlbackup"',
                        'BACKUPDIR="/data/automysqlbackup"', )

cmanager.get(InstallCommand.NAME).register(InstallAutoMySQLBackupCommand.NAME, InstallAutoMySQLBackupCommand())
コード例 #9
0
ファイル: install_awstats.py プロジェクト: pylanglois/uwsa
#!/usr/bin/env python
# coding=UTF-8

__author__ = "Pierre-Yves Langlois"
__copyright__ = "https://github.com/pylanglois/uwsa/blob/master/LICENCE"
__credits__ = ["Pierre-Yves Langlois"]
__license__ = "BSD"
__maintainer__ = "Pierre-Yves Langlois"

from uwsas.common import *
from uwsas.core import L

from uwsas.commands.command_manager import cmanager
from uwsas.commands.install import InstallCommand

class InstallAWStatsCommand(InstallCommand):

    NAME = 'awstats'

    def __init__(self):
        InstallCommand.__init__(self)
        self.packages = "awstats"
        self.add_package(self.packages)

cmanager.get(InstallCommand.NAME).register(InstallAWStatsCommand.NAME, InstallAWStatsCommand())
コード例 #10
0
ファイル: install_toptools.py プロジェクト: pylanglois/uwsa
__maintainer__ = "Pierre-Yves Langlois"

from uwsas.common import *
from uwsas.core import L

from uwsas.commands.command_manager import cmanager
from uwsas.commands.install import InstallCommand

class InstallTopToolsCommand(InstallCommand):

    NAME = 'toptools'

    def __init__(self):
        InstallCommand.__init__(self)
        self.packages = "iotop htop jnettop nethogs apachetop sysstat dstat ifstat latencytop mytop ntop iperf"
        self.add_package(self.packages)

    #TODO
    #def set_ntop_admin_pass(new_password):
    #    cmd_list = [
    #        {
    #            'command': "ntop --set-admin-password=%s" % new_password,
    #            'anonymous' : "ntop --set-admin-password=%s" % "XXXXXXXXXXXXXX",
    #        }
    #    ]
    #    completed, pinfo = exec_cmd_list(cmd_list)
    #    if not completed:
    #        raise Exception("Error in installation!")

cmanager.get(InstallCommand.NAME).register(InstallTopToolsCommand.NAME, InstallTopToolsCommand())
コード例 #11
0
ファイル: install_fail2ban.py プロジェクト: pylanglois/uwsa
#!/usr/bin/env python
# coding=UTF-8

__author__ = "Pierre-Yves Langlois"
__copyright__ = "https://github.com/pylanglois/uwsa/blob/master/LICENCE"
__credits__ = ["Pierre-Yves Langlois"]
__license__ = "BSD"
__maintainer__ = "Pierre-Yves Langlois"

from uwsas.common import *
from uwsas.core import L
from uwsas.core import CONF_MAP

from uwsas.commands.command_manager import cmanager
from uwsas.commands.install import InstallCommand


class InstallFail2BanCommand(InstallCommand):

    NAME = "fail2ban"

    def __init__(self):
        InstallCommand.__init__(self)
        self.packages = "fail2ban"
        self.add_package(self.packages)


cmanager.get(InstallCommand.NAME).register(InstallFail2BanCommand.NAME, InstallFail2BanCommand())
コード例 #12
0
ファイル: install_munin_node.py プロジェクト: pylanglois/uwsa
        self.add_file('/etc/munin/munin-node.conf', 
                        ck_func=self.check_munin_master_ip, 
                        fix_func=self.fix_munin_master_ip)
        self.master_ip = self.LOCIP
        conf = CONFIG.get()
        if not CONFIG.is_set(self.NAME,'master_ip'):
            self.master_ip = None
        else:
            self.master_ip = conf[self.NAME]['master_ip']

    def check_munin_master_ip(self, element):
        is_ok = True
        if self.master_ip:
            mip = "\nallow ^%s$\n" % self.master_ip.replace('.','\.')
            is_ok &= files.contains(element['name'],mip)

        return is_ok

    def fix_munin_master_ip(self, element):

        if self.master_ip:
            mip = "allow ^%s$\n" % self.master_ip.replace('.','\.')
            loc_n_mip = LOCIP + mip
            if not files.contains(element['name'], loc_n_mip):
                files.replace_in(element['name'],
                                self.LOCIP, 
                                loc_n_mip)


cmanager.get(InstallCommand.NAME).register(InstallMuninNodeCommand.NAME, InstallMuninNodeCommand())
コード例 #13
0
ファイル: install_grub_gfx.py プロジェクト: pylanglois/uwsa
from uwsas.helpers import files

class InstallGrubGFXCommand(InstallCommand):

    NAME = 'grub_gfx'

    def __init__(self):
        InstallCommand.__init__(self)
        self.add_file('/etc/default/grub', 
                        ck_func=self.check_grub, 
                        fix_func=self.fix_grub)

    def check_grub(self, element):
        is_ok = True
        is_ok &= files.contains(element['name'], 'GRUB_GFXMODE=1024x768\nGRUB_GFXPAYLOAD_LINUX=1024x768\n')
        return is_ok

    def fix_grub(self, element):
        files.replace_in(element['name'],
                        '#GRUB_GFXMODE=640x480\n',
                        'GRUB_GFXMODE=1024x768\nGRUB_GFXPAYLOAD_LINUX=1024x768\n')
        cmd_list = [
            "update-grub",
        ]
        completed, pinfo = core.exec_cmd_list(cmd_list)
        if not completed:
            raise Exception(t("Error in installation!"), element['name'])


cmanager.get(InstallCommand.NAME).register(InstallGrubGFXCommand.NAME, InstallGrubGFXCommand())