auto-install script

This commit is contained in:
undefined committed 2020-10-30 14:11:41 +08:00
1 parent 2efc241c56
commit 3af3453166
2 files changed
+53 -17

No files matched your search

+2 -2
View File
@@ -1,6 +1,6 @@
# These are supported funding model platforms
github: [masnn]
github: [undefined-moe]
patreon: # Replace with a single Patreon username
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
@@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: ['https://masnn.ml']
custom: ['https://undefined.moe']
+51 -15
View File
@@ -1,32 +1,68 @@
#!/bin/bash
echo "Running Hydro Installer for ubuntu"
db_password=$(cat /dev/urandom | head -n 10 | md5sum | head -c 20)
# Basic
apt-get update
apt-get install curl wget unzip gnupg -y
echo "apt-get update"
apt-get -qq update
echo "apt-get install curl wget unzip gnupg -y"
apt-get install -y curl wget unzip gnupg >/dev/null
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu bionic/mongodb-org/4.0 multiverse" | tee /etc/apt/sources.list.d/mongodb-org-4.0.list
apt-get update
# Install MongoDB
apt-get install -y mongodb-org
apt-get clean
mkdir -p /data/db
echo "apt-get update"
apt-get -qq update
# Install NodeJS
echo "Installing NodeJS"
curl -o- https://cdn.jsdelivr.net/gh/nvm-sh/nvm@v0.36.0/install.sh | sed 's/raw.githubusercontent.com\/nvm-sh\/nvm\//cdn.jsdelivr.net\/gh\/nvm-sh\/nvm@/g' | bash
export NVM_DIR=/root/.nvm
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
nvm install 14
nvm use 14
npm i yarn -g
echo "Installing pm2"
yarn global add pm2
# Install MongoDB
echo "Installing MongoDB"
apt-get -qq install -y mongodb-org
mkdir -p /data/db
echo "db.createUser({
user: 'hydro',
pwd: '$db_password',
roles: [
{ role: 'readWrite', db: 'hydro' }
]
})" >/tmp/createUser.js
echo "pm2 start mongod"
pm2 start mongod >/dev/null
sleep 2
mongo 127.0.0.1:27017/hydro /tmp/createUser.js
rm /tmp/createUser.js
echo "pm2 stop mongod"
pm2 stop mongod >/dev/null
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 HydroOJ
npm i yarn -g
# 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"
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
pm2 start hydrooj
# TODO: auto-config & start? pm2 daemon?
# Finish
echo "Done! use 'hydrooj' to start."
# TODO: install judge
# Done
echo "Done"
echo "Database username: hydro"
echo "Database password: $db_password"