Example #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'")
Example #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()
Example #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()
Example #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()
Example #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()
Example #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)
Example #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)
Example #8
0
def create_www_user():
    try:
        pwd.getpwnam('www')
    except KeyError:
        system.sudo(["useradd", "-M", "www"])
Example #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"])
Example #10
0
def create_www_user():
    try:
        pwd.getpwnam('www')
    except KeyError:
        system.sudo(["useradd", "-M", "www"])
Example #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"])
Example #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'")