Ejemplo n.º 1
0
def main(argv=["worker_setup.py"]):
    """ Completely set everything up from a fresh ec2 instance """
    opts = get_options(argv)
    with Environ("DEBIAN_FRONTEND", "noninteractive"):
        if opts.update_system:
            run_cmd("apt-get update")
            run_cmd("apt-get upgrade -y")
        if opts.install_required:
            install_required_packages()
        if opts.install_utilities:
            install_utility_packages()
        if opts.install_languages:
            install_all_languages()
    if opts.packages_only:
        return
    setup_contest_files(opts)
    if opts.create_jails:
        setup_jailusers(opts)
    start_script = os.path.join(opts.root_dir, opts.local_repo,
            "worker/start_worker.sh")
    if opts.install_cronjob:
        cron_file = "/etc/cron.d/ai-contest"
        if not file_contains(cron_file, start_script):
            append_line(cron_file, "@reboot root %s" % (start_script,))
    if opts.run_worker:
        run_cmd(start_script)
Ejemplo n.º 2
0
def main(argv=["server_setup.py"]):
    opts = get_options(argv)
    with Environ("DEBIAN_FRONTEND", "noninteractive"):
        for install in opts.installs:
            install()
    if opts.packages_only:
        return
    setup_base_files(opts)
    setup_website(opts)
Ejemplo n.º 3
0
def main(argv=["server_setup.py"]):
    opts = get_options(argv)
    with Environ("DEBIAN_FRONTEND", "noninteractive"):
        for install in opts.installs:
            install()
    if opts.packages_only:
        return
    if opts.create_user:
        create_contest_user(opts.username)
    root_dir = opts.root_dir.replace("$user", opts.username)
    if not os.path.exists(root_dir):
        os.makedirs(root_dir)
    opts.root_dir = root_dir
    if opts.update_local_repo:
        setup_local_repo(opts)
    setup_base_files(opts)
    setup_database(opts)
    setup_website(opts)