OI赛制比赛的终测,一个评测机显然是不够的。200人的比赛,要10台评测机,7分钟才能测完。(成本大概10块钱?)

但是这些评测机平时闲置着又很浪费,于是我参考uoj开源版文档,写了一个一键配置脚本。配合阿里云的机器hostname自动顺序命名来使用。

#!/bin/bash

echo STEP1
sudo apt-get update
sudo apt-get -y install apt-transport-https ca-certificates curl software-properties-common

echo STEP2
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get -y update
sudo apt-get -y install docker-ce

echo STEP3
sudo service docker start 
sudo docker --version 
sudo docker pull universaloj/uoj-system:judger



# https://universaloj.github.io/post/%E5%A4%9A%E8%AF%84%E6%B5%8B%E6%9C%BA%E9%85%8D%E7%BD%AE.html

echo STEP4
echo "172.31.41.20 host.name" >> /etc/hosts


echo "UOJ_PROTOCOL=http" > judger_env.list
echo "UOJ_HOST=host.name" >> judger_env.list
echo "JUDGER_NAME=$(hostname)" >> judger_env.list
echo "JUDGER_PASSWORD=JUDGER_PASSWORD_HERE" >> judger_env.list
echo "SOCKET_PORT=2333" >> judger_env.list
echo "SOCKET_PASSWORD=SOCKET_PASSWORD_HERE" >> judger_env.list

sudo docker run --name $(hostname) -p 2333:2333 -dit --env-file judger_env.list --cap-add SYS_PTRACE universaloj/uoj-system:judger

touch ~/init_done
cat /etc/hosts
cat /etc/hosts | grep $(hostname)

todo: 尝试使用pwntools等类似工具自动化ssh,做到批量添加&删除评测机0手动。