예제 #1
0
def build(module_params):
    if assembly.get_dist() == 'centos':

        sudo("yum install -y epel-release")
        assembly.install_distro_dependencies(
            ['sudo', 'vim', 'git', 'htop', 'fail2ban'])
        sudo("yum groupinstall 'Development Tools'")
예제 #2
0
def install_distro_dependencies(dependencies):
    distro = get_dist()
    package_manager_install_command = {
        "Ubuntu": ['apt-get', 'install', "-y"],
        "Centos": ["yum", 'install', '-y']
    }
    command = package_manager_install_command[distro] + dependencies
    with open('log/install_deps.log', 'a+') as log:
        dep_process = sudo(command, stderr=log, stdout=log)
        dep_process.communicate()
예제 #3
0
def make_install(directory):
    print("Installing project in " + directory)
    log_file = os.path.join(sys_config.log_folder, 'make_install.log')
    with open(log_file, 'a+') as log_file:
        TemporaryDir.enter(directory)
        process = sudo(['make', 'install'], stdout=log_file, stderr=log_file)
        if process.returncode != 0:
            raise Exception("'MAKE INSTALL' finished with status-code " + str(process.returncode))
            sys.exit(1)
        TemporaryDir.leave()
예제 #4
0
def install_distro_dependencies(dependencies):
    distro = get_dist()
    package_manager_install_command = {
        "Ubuntu": ['apt-get', 'install', "-y"],
        "Centos": ["yum", 'install', '-y']
    }
    command = package_manager_install_command[distro] + dependencies
    with open('log/install_deps.log', 'a+') as log:
        dep_process = sudo(command, stderr=log, stdout=log)
        dep_process.communicate()
예제 #5
0
def make_install(directory):
    print("Installing project in " + directory)
    log_file = os.path.join(sys_config.log_folder, 'make_install.log')
    with open(log_file, 'a+') as log_file:
        TemporaryDir.enter(directory)
        process = sudo(['make', 'install'], stdout=log_file, stderr=log_file)
        if process.returncode != 0:
            raise Exception("'MAKE INSTALL' finished with status-code " +
                            str(process.returncode))
            sys.exit(1)
        TemporaryDir.leave()
예제 #6
0
def copy(path_to_file_or_dir, destination, overwrite=False, sudo=False):
    file = path_to_file_or_dir

    if os.path.exists(destination):
        if overwrite:
            if sudo:
                system.sudo(["rm", "-rf", destination])
            else:
                remove(destination)
        else:
            raise Exception('Destination file "%s" exists' % destination)

    require_full_path(destination)
    if sudo:
        system.sudo(["cp", "--remove-destination", path_to_file_or_dir, destination])
    else:
        if os.path.isdir(file):
            copytree(file, destination)
        elif os.path.isfile(file):
            copyfile(file, destination)
예제 #7
0
def copy(path_to_file_or_dir, destination, overwrite=False, sudo=False):
    file = path_to_file_or_dir

    if os.path.exists(destination):
        if overwrite:
            if sudo:
                system.sudo(["rm", "-rf", destination])
            else:
                remove(destination)
        else:
            raise Exception('Destination file "%s" exists' % destination)

    require_full_path(destination)
    if sudo:
        system.sudo(
            ["cp", "--remove-destination", path_to_file_or_dir, destination])
    else:
        if os.path.isdir(file):
            copytree(file, destination)
        elif os.path.isfile(file):
            copyfile(file, destination)
예제 #8
0
def create_www_user():
    try:
        pwd.getpwnam('www')
    except KeyError:
        system.sudo(["useradd", "-M", "www"])
예제 #9
0
def change_configs():
    fs.copy("nginx.conf", "/etc/nginx/nginx.conf", True, True)
    if os.path.exists("/etc/nginx/configs"):
        system.sudo(["rm", "-rf", "/etc/nginx/configs"])
    system.sudo(["mkdir", "/etc/nginx/configs"])
예제 #10
0
def create_www_user():
    try:
        pwd.getpwnam('www')
    except KeyError:
        system.sudo(["useradd", "-M", "www"])
예제 #11
0
def change_configs():
    fs.copy("nginx.conf", "/etc/nginx/nginx.conf", True, True)
    if os.path.exists("/etc/nginx/configs"):
        system.sudo(["rm", "-rf", "/etc/nginx/configs"])
    system.sudo(["mkdir", "/etc/nginx/configs"])
예제 #12
0
def build(module_params):
    if assembly.get_dist() == "centos":

        sudo("yum install -y epel-release")
        assembly.install_distro_dependencies(["sudo", "vim", "git", "htop", "fail2ban"])
        sudo("yum groupinstall 'Development Tools'")