Skip to content
Snippets Groups Projects
0_setup.py 1.43 KiB
#!/usr/bin/env python3

import utils

packages = [
    "bmon",
    "curl",
    "git",
    "host",
    "htop",
    "iotop",
    "ipython3",
    "lm-sensors",
    "make",
    "net-tools",
    "netcat",
    "nfs-client",
    "pciutils",
    "pwgen",
    "python3-openssl",
    "python3-psutil",
    "python3-requests",
    "python3-spf",
    "smartmontools",
    "sudo",
    "vim",
]


def setup(interactive=True):
    dir_path = utils.get_dir(__file__)
    cmds = [
        "apt-get clean",
        "apt-get update",
        "apt-get install --yes {}".format(" ".join(packages)),
        # Locale
        "sed -i 's@# en_GB.UTF-8 UTF-8@en_GB.UTF-8 UTF-8@' /etc/locale.gen",
        "locale-gen 'en_GB.UTF-8'",
        "locale -a",
        "update-locale LANG='en_GB.UTF-8' LANGUAGE='en_GB.UTF-8' LC_ALL='en_GB.UTF-8' LC_ADDRESS='en_GB.UTF-8' LC_COLLATE='en_GB.UTF-8' LC_CTYPE='en_GB.UTF-8' LC_IDENTIFICATION='en_GB.UTF-8' LC_MEASUREMENT='en_GB.UTF-8' LC_MESSAGES='en_GB.UTF-8' LC_MONETARY='en_GB.UTF-8' LC_NAME='en_GB.UTF-8' LC_NUMERIC='en_GB.UTF-8' LC_PAPER='en_GB.UTF-8' LC_TELEPHONE='en_GB.UTF-8' LC_TIME='en_GB.UTF-8'",
        # Copy vimrc file
        "cp '{}/vimrc' /root/.vimrc".format(dir_path),
        # Copy bashrc file
        "cp '{}/bashrc' /root/.bashrc".format(dir_path),
        # Generate SSH key if not already done
        "[ -f /root/.ssh/id_rsa ] || ssh-keygen -b 4096 -t rsa -f /root/.ssh/id_rsa -P ''",
    ]
    utils.run_commands(cmds)