Beispiel #1
0
def git_repo(path, bare=True):

    def repo_exist():
        return os.path.exists(path)

    shell(
        'git init %s%s' % ('--bare ' if bare else '', path),
        'rm -rf %s' % path,
        if_not=repo_exist,
        description='Create %srepository at %s' % ('bare ' if bare else '', path)
    )
Beispiel #2
0
def git_clone(url, path, branch=None):

    def repo_exist():
        return os.path.exists(path)

    branch_name = ('branch %s' % branch) if branch else ''
    shell(
        'git clone %s%s %s' % (branch or '', url, path),
        'rm -rf %s' % path,
        if_not=repo_exist,
        description='Clone repository %sfrom %s into %s' % (branch_name, url, path)
    )
Beispiel #3
0
def mysql_server(**kwargs):

    require_sudo(reason='Only root can install mysql server.')

    def init_root_password():
        root_password = get_password_for_user('mysql', 'root', purpose='Password for mysql server')

        root_password = subprocess.list2cmdline([root_password])

        if is_ubuntu():
            run('echo mysql-server mysql-server/root_password password %s | debconf-set-selections' % root_password,
                secrets=[])
            run('echo mysql-server mysql-server/root_password_again password %s | debconf-set-selections' % root_password,
                secrets=(root_password,))

    def init_root_password_():
        root_password = get_password_for_user('mysql', 'root', purpose='Password for mysql server')
        if is_centos():
            run("service mysqld start")
            run("mysqladmin -u root password '%s'" % root_password)

    package('mysql-server', before_install=init_root_password, after_install=init_root_password_)

    if is_centos():
        mysql_service_name = 'mysqld'
        my_cnf = '/etc/my.cnf'
    elif is_ubuntu():
        mysql_service_name = 'mysql'
        my_cnf = '/etc/mysql/my.cnf'
    else:
        raise NotImplemented

    mysql_service = service(mysql_service_name, process_name='mysqld', start=True)

    def restart():
        mysql_service.restart()

    if is_centos():
        shell('/sbin/chkconfig mysqld on')