diff --git a/README.md b/README.md index f576d1eb..fed739a8 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,6 @@ Hydro是一个高效的信息学在线测评系统。特点:易于部署,轻 curl -sSL https://cdn.jsdelivr.net/gh/hydro-dev/Hydro@master/install/ubuntu-1604.sh | bash # ubuntu 16.04 curl -sSL https://cdn.jsdelivr.net/gh/hydro-dev/Hydro@master/install/ubuntu-1804.sh | bash # ubuntu 18.04 curl -sSL https://cdn.jsdelivr.net/gh/hydro-dev/Hydro@master/install/ubuntu-2004.sh | bash # ubuntu 20.04 -# 下方脚本未测试有效性,请尽量避免使用 curl -sSL https://cdn.jsdelivr.net/gh/hydro-dev/Hydro@master/install/centos-7.sh | bash # centos 7 ``` diff --git a/install/centos-7.sh b/install/centos-7.sh index bfffea54..3dd24d12 100644 --- a/install/centos-7.sh +++ b/install/centos-7.sh @@ -6,6 +6,7 @@ MINIO_ACCESS_KEY=$(cat /dev/urandom | head -n 10 | md5sum | head -c 20) MINIO_SECRET_KEY=$(cat /dev/urandom | head -n 10 | md5sum | head -c 20) # Basic +yum install wget mkdir -p /etc/yum.repos.d echo "[mongodb-org-4.4] name=MongoDB Repository @@ -17,7 +18,8 @@ echo "yum install -y mongodb-org" yum install -y mongodb-org mkdir -p /var/lib/mongo mkdir -p /var/log/mongodb -chown -R mongod:mongod /var/lib/mongo /var/log/mongodb +mkdir -p /data/db +chown -R mongod:mongod /var/lib/mongo /var/log/mongodb /data/db # Install NodeJS echo "Installing NodeJS" @@ -50,10 +52,6 @@ pm2 del mongod >/dev/null echo 'pm2 start "mongod --auth"' pm2 start "mongod --auth" -# Install Compiler -echo 'Installing g++' -apt-get install -y g++ >/dev/null - # Install MinIO echo 'Installing MinIO' wget https://dl.min.io/server/minio/release/linux-amd64/minio @@ -65,9 +63,9 @@ pm2 start "./minio server /data/file" --name minio # TODO: install basic addons? echo "Installing Hydro" yarn global add hydrooj @hydrooj/ui-default @hydrooj/hydrojudge -wget https://github.com/criyle/go-judge/releases/download/v0.7.1/executorserver-amd64 -O /usr/bin/sandbox -chmod +x /usr/bin/sandbox -pm2 start "/usr/bin/sandbox" +wget https://github.com/criyle/go-judge/releases/download/v0.9.4/executorserver-amd64 -O /usr/bin/sandbox_ +chmod +x /usr/bin/sandbox_ +pm2 start "/usr/bin/sandbox_" mkdir ~/.hydro echo "{\"host\":\"127.0.0.1\",\"port\":\"27017\",\"name\":\"hydro\",\"username\":\"hydro\",\"password\":\"$db_password\"}" >~/.hydro/config.json echo '["@hydrooj/ui-default","@hydrooj/hydrojudge"]' >~/.hydro/addon.json @@ -77,3 +75,5 @@ pm2 start hydrooj echo "Done" echo "Database username: hydro" echo "Database password: $db_password" +echo "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY +MINIO_SECRET_KEY=$MINIO_SECRET_KEY" >~/.hydro/env diff --git a/install/ubuntu-1604.sh b/install/ubuntu-1604.sh index c1192679..29fa909c 100644 --- a/install/ubuntu-1604.sh +++ b/install/ubuntu-1604.sh @@ -75,4 +75,6 @@ pm2 save # Done echo "Done" echo "Database username: hydro" -echo "Database password: $db_password" \ No newline at end of file +echo "Database password: $db_password" +echo "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY +MINIO_SECRET_KEY=$MINIO_SECRET_KEY" >~/.hydro/env diff --git a/install/ubuntu-1804.sh b/install/ubuntu-1804.sh index 86fe4ee2..339bc870 100644 --- a/install/ubuntu-1804.sh +++ b/install/ubuntu-1804.sh @@ -75,4 +75,6 @@ pm2 save # Done echo "Done" echo "Database username: hydro" -echo "Database password: $db_password" \ No newline at end of file +echo "Database password: $db_password" +echo "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY +MINIO_SECRET_KEY=$MINIO_SECRET_KEY" >~/.hydro/env diff --git a/install/ubuntu-2004.sh b/install/ubuntu-2004.sh index a9a3f069..d576d81c 100644 --- a/install/ubuntu-2004.sh +++ b/install/ubuntu-2004.sh @@ -75,4 +75,6 @@ pm2 save # Done echo "Done" echo "Database username: hydro" -echo "Database password: $db_password" \ No newline at end of file +echo "Database password: $db_password" +echo "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY +MINIO_SECRET_KEY=$MINIO_SECRET_KEY" >~/.hydro/env diff --git a/packages/hydrooj/package.json b/packages/hydrooj/package.json index 0279cd13..691de15b 100644 --- a/packages/hydrooj/package.json +++ b/packages/hydrooj/package.json @@ -1,6 +1,6 @@ { "name": "hydrooj", - "version": "2.15.6", + "version": "2.15.7", "bin": "bin/hydrooj.js", "main": "dist/loader.js", "typings": "dist/loader.d.ts", diff --git a/packages/hydrooj/src/options.ts b/packages/hydrooj/src/options.ts index 4ee655c1..19feaa4f 100644 --- a/packages/hydrooj/src/options.ts +++ b/packages/hydrooj/src/options.ts @@ -6,6 +6,14 @@ import { Logger } from './logger'; const logger = new Logger('options'); export = function load() { + const envFile = path.resolve(os.homedir(), '.hydro', 'env'); + if (fs.existsSync(envFile)) { + const content = fs.readFileSync(envFile).toString(); + for (const line of content.split('\n')) { + process.env[line.split('=')[0]] = line.split('=')[1]; + } + } + let f = path.resolve(process.cwd(), 'config.json'); if (!fs.existsSync(f)) f = path.resolve(__dirname, 'config.json'); if (!fs.existsSync(f)) f = path.resolve(os.homedir(), '.config', 'hydro', 'config.json');