-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.sh
111 lines (89 loc) · 3.81 KB
/
bootstrap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
######## DO NOT EDIT THIS FILE UNLESS YOU KNOW WHAT YOU ARE DOING #############
# vagrant up - for booting the VM
# vagrant halt - for shutdown the VM (gracefully)
# vagrant suspend - for suspending the VM (logout & stores the state)
# vagrant resume - for resuming the VM (login & state will be restored)
# vagrant destroy - for destroying the VM (VM instance will be removed)
########### FIRST TIME BOOTED THE VM? ADD THESE JUDGE ID & AUTHENTICATION KEY IN THE WEBSITE -> ADMIN -> JUDGES -> ADD JUDGE
# This is the same ID you should specified in the judge admin panel
# id: Tier1
# The key this judge will use to authenticate with the site server, generated from the admin panel
# key: FC0YtcfeAq+NbrS7O8VFWaEpLiuU3wOwGXAJ42w4tjCmQK0fWyrhYaZImg7Vdjbwlg2X0PyPuZgW8az6pVrUCXn34ij51lj965/x
# Once Judge added, it will show the up status in ABOUT -> STATUS page
# Also change the ADMIN panel -> sites -> edit localhost:8081 to localhost:8080
####### START ########
# Update packages
apt -y update
#Install All necessary packages
apt -y install git gcc g++ make python3-dev python3-pip libxml2-dev libxslt1-dev zlib1g-dev gettext curl redis-server
#Install NodeJS stuff
export DEBIAN_FRONTEND=noninteractive
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
apt -y --force-yes install nodejs
npm install -g sass postcss-cli postcss autoprefixer
#Install MySQL database server
debconf-set-selections <<< 'mysql-server mysql-server/root_password password root'
debconf-set-selections <<< 'mysql-server mysql-server/root_password_again password root'
apt -y install mariadb-server libmysqlclient-dev
#Create DMOJ database only once per VM
if [ ! -f /var/log/databasesetup ];
then
echo "CREATE DATABASE dmoj DEFAULT CHARACTER SET utf8mb4 DEFAULT COLLATE utf8mb4_general_ci" | mysql -uroot -proot
echo "GRANT ALL PRIVILEGES ON dmoj.* to 'root'@'localhost' IDENTIFIED BY 'root'" | mysql -uroot -proot
echo "flush privileges" | mysql -uroot -proot
touch /var/log/databasesetup
if [ -f /vagrant/data/initial.sql ];
then
mysql -uroot -proot dmoj < /vagrant/data/initial.sql
fi
fi
#Clone & Build the online-judge repo
apt -y install python3.8-venv
python3 -m venv venv
git clone --recursive https://github.com/maradanasai/online-judge.git
cd online-judge
git checkout local
../venv/bin/pip3 install -r requirements.txt
../venv/bin/pip install mysqlclient
#../venv/bin/python3 -m pip install PyMySQL
../venv/bin/python3 manage.py check
#Compile assests
./make_style.sh
../venv/bin/python3 manage.py collectstatic --no-input
../venv/bin/python3 manage.py compilemessages
../venv/bin/python3 manage.py compilejsi18n
#Setting up database tables
../venv/bin/python3 manage.py migrate
../venv/bin/python3 manage.py loaddata navbar
../venv/bin/python3 manage.py loaddata language_small
../venv/bin/python3 manage.py loaddata demo
#Setting up supervisord for `site` and `bridged`
apt -y install supervisor
cp ./config/site.conf /etc/supervisor/conf.d
cp ./config/bridged.conf /etc/supervisor/conf.d
cp ./config/celery.conf /etc/supervisor/conf.d
cp ./config/wsevent.conf /etc/supervisor/conf.d
cp ./config/judge.conf /etc/supervisor/conf.d
cp ./config/judge_rest.conf /etc/supervisor/conf.d
#Setting up nginx
apt -y install nginx
cp ./config/nginx.conf /etc/nginx/conf.d
#Configuration of event server
cp ./config/config.js ./websocket
npm install qu ws simplesets
#Setting up Judge
apt -y install build-essential libseccomp-dev openjdk-8-jdk-headless
../venv/bin/pip3 install dmoj
#Setting up REST Api Judge
cd ..
git clone --recursive https://github.com/maradanasai/judge-server.git
cd judge-server
git checkout judge_restapi
python3 -m venv venv
./venv/bin/pip3 install -r requirements.txt
./venv/bin/pip3 install -e .
#Reload all configuration changes
supervisorctl update
supervisorctl restart all
service nginx restart
######### END ###########