mirror of
https://gitcode.com/gh_mirrors/hy/Hydro.git
synced 2026-10-17 17:36:08 +08:00
feat: 从~/.hydro/env读取环境变量
This commit is contained in:
1 parent
e3dad8ff60
commit
c6b67bb1a8
7 files changed
+26
-13
No files matched your search
@@ -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
|
||||
```
|
||||
|
||||
|
||||
+8
-8
@@ -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
|
||||
@@ -75,4 +75,6 @@ pm2 save
|
||||
# Done
|
||||
echo "Done"
|
||||
echo "Database username: hydro"
|
||||
echo "Database password: $db_password"
|
||||
echo "Database password: $db_password"
|
||||
echo "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY
|
||||
MINIO_SECRET_KEY=$MINIO_SECRET_KEY" >~/.hydro/env
|
||||
@@ -75,4 +75,6 @@ pm2 save
|
||||
# Done
|
||||
echo "Done"
|
||||
echo "Database username: hydro"
|
||||
echo "Database password: $db_password"
|
||||
echo "Database password: $db_password"
|
||||
echo "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY
|
||||
MINIO_SECRET_KEY=$MINIO_SECRET_KEY" >~/.hydro/env
|
||||
@@ -75,4 +75,6 @@ pm2 save
|
||||
# Done
|
||||
echo "Done"
|
||||
echo "Database username: hydro"
|
||||
echo "Database password: $db_password"
|
||||
echo "Database password: $db_password"
|
||||
echo "MINIO_ACCESS_KEY=$MINIO_ACCESS_KEY
|
||||
MINIO_SECRET_KEY=$MINIO_SECRET_KEY" >~/.hydro/env
|
||||
@@ -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",
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in new issue
Block a user