BOCADocumentation
BOCA documentation. Installing and configuring BOCA. Auto judge configuration. Database Replication (PostgreSQL). Database Restore (PostgreSQL). "Animeitor" Configuration
Install / Use
/learn @gabrielrbernardi/BOCADocumentationREADME
Introduction
This repository contains the documentation for installing and configuring a system with BOCA Online Contest Administrator, database replication for PostgreSQL, and Animeitor.
BOCA
Use Ubuntu Server 22.04 LTS to install and configure BOCA package.
sudo apt-get update # Updating packages
sudo add-apt-repository ppa:icpc-latam/maratona-linux # Adding the official package of BOCA
sudo apt-get update # Updating packages, again
sudo apt-get install boca -y # Installing BOCA
In this process, you should be prompted to locate the database location. By default, The database is placed on the same machine as the BOCA web. After this, you should be prompted for database password creation. Don't forget this password because you'll need it for future steps. There's an additional step in order to modificate pg_hba.conf file. To this, you'll need to accept modifications from BOCA package maintainer. After this, you should be prompted again to put the database password. The installation asks you to create a fake initial contest if this database password is correct.
After this, the installation will be completed and BOCA can be accessed at http://localhost/boca.
Removing /boca on the URL
To remove the /boca on the URL, you need to configure a file from Apache, that redirects to the BOCA system.
The file is located on /etc/apache2/sites-enabled/000-boca.conf. Edit this file with your preferred text editor. Inside this file, you must locate a line that contains DocumentRoot /var/www/boca/. Add src at the end of this line. The final result should be like this
DocumentRoot /var/www/boca/src
systemctl stop apache2
systemctl start apache2
Database configuration
If you want, you can install BOCA on other machines and use them as autojudges. For this, you need to configure a PostgreSQL file, that is located at /etc/postgresql/14/main/postgresql.conf. Search on this file for listen_addresses. On this line, you must set this listen_addresses to allow connection from all locations. The final result should be this: listen_addresses = '*'. Save this file and close.
Installing Auto Judges
There are two possibilities to run an auto-judge system. One of them is the local installation, on the same machine that runs BOCA's database. Another one is to install an auto-judge system on another machine.
Local Auto Judges
For automatically judging exercises, you'll need to install the autojudge. This tool is a robot that will connect to the database and waits for newer runs, that have been sent by the competitors. To install this, you'll need to run the following commands:
boca-createjail # This installation process can be time-consuming
After this, you can run autojudge by typing sudo boca-autojudge. If you prefer, this tool can be run in the background. To make this, nohup can be used. To use this, you can run sudo nohup boca-autojudge & on the terminal and hit the enter key. With nohup a file will be created that contains all the default output of the command. This file is stored on the same directory that you run autojudge. If you run the command while you're in the home folder, the file will be there.
External Auto Judges
With this type of setup, you could run a self-judging system using another machine, which could be dedicated to judging contest exercises.
To run it, you will install BOCA on this machine (Follow previous steps). After the installation is completed, you will have to configure a single file, which points the self-trial connection to the main machine. The machine running the dedicated self-trial need not be the second machine in the replication steps.
Firstly, you will need to run the following commands as a superuser.
-
Locate the
conf.phpfile. By default, it can be found at/var/www/boca/src/private.sudo su cd /var/www/boca/src/private -
Open the file using your preferred text editor.
nano conf.php -
Locate the line containing
$conf["dbhost"]=. Replace the contents of this line (underlocalhost) with the IP address of the machine running the BOCA database. Insert this IP address under double quotes$conf["dbhost"]="BOCADatabaseIPAddress"; -
Verify that the port the database is on, on the main machine, is the default (port 5432). Otherwise, overwrite this information in the file with the current port.
-
Insert the credentials that will be used to connect to this database. Locate the line that contains
$conf["dbpass"]=and insert the password of the primary database, to connect to him. Insert this password under double quotes.$conf["dbpass"]="SecretPassword"; -
Insert the credentials that will be used to connect to this database, with privileged permissions. Locate the line that contains
$conf["dbsuperpass"]=and insert the password of the primary database, to connect to him. Insert this password under double quotes.$conf["dbsuperpass"]="SecretPassword"; -
By default, BOCA creates a user named
bocauserand the password for him is the password that you set on the BOCA installation process. If you don't want to use this user, change this onconf.php(Locate the line that contains$conf["dbhost"]="bocauser"and the line that contains$conf["dbsuperuser"]="bocauser"and change this user to the user that you define). -
After these previous steps, the file should have the pieces of information that you've inserted, and look like this:
$conf["dbhost"]="BOCADatabaseIPAddress"; $conf["dbport"]="5432"; $conf["dbname"]="bocadb"; // name of the boca database $conf["dbuser"]="bocauser"; // unprivileged boca user $conf["dbpass"]="SecretPassword"; $conf["dbsuperuser"]="bocauser"; // privileged boca user $conf["dbsuperpass"]="SecretPassword"; -
Save this file. After this, the connection of auto-judge will be on the main BOCA database.
Killing autojudge
To kill autojudge that is running in the background, you can get the PID value and terminate this process.
ps -aux | grep autoj # Get the information from the process
kill -9 PID_VALUE
Animeitor
The "Animeitor" is a tool, developed in Rust, that shows a customized scoreboard, that can be followed during the competition. With this tool, you can have another one called "Reveleitor". The "Reveleitor" tool shows the scoreboard between the freeze time and the end of the contest. Here, we have two parts. The first one, you'll configure the server that runs BOCA web. The second one you'll configure the machine that will run "Animeitor".
Configuring the BOCA web server
The "Animeitor" will access BOCA through the BOCA web. To allow this, you'll have to configure a file, that allows this connection between the machine that runs animeitor and the one that runs BOCA web, without needing to authenticate as an administrator.
-
You have to create a file called
webcast.sep, inside/var/www/boca/src/privatedirectory. On this file, you must set the webcast code which is like a "credential" to access the webcast file, and the range of users that belongs to this webcast code. Here is a sample:allUsers 1/1000/9000allUsersis the webcast code; 1 is the site that belongs to the current activated contest; 1000 is the first user ID; 9000 is the last user ID. -
After this, you can test if the configuration is working well. To this, access BOCA web and make a request to the webcast file. This file is a compacted one.
wget https://IPBOCAWeb/admin/report/webcast.php?webcastcode=allUsers -O t.zipInside this downloaded file, you should have 5 other files:
contest,icpc,runs,time, andversion. If these files are in, the configuration is ok. -
If you have more than one competition in BOCA's database, you must set up another file that points this webcast to the desired competition.
-
For that, you must open the
webcast.phpfile, which is in/var/www/boca/src/admin/report/.nano /var/www/boca/src/admin/report/webcast.php -
Locate the line containing
$contest. The result should look something like this:$contest = 42; //$_SESSION["usertable"]["contestnumber"]; -
Change this contest value to the current contest, which can be located after logging in to BOCA web as admin, on the "Contest" tab, with the label "Contest number:".
-
Save this file.
-
-
After you load the
insert-userfile, you have to check if inside the/var/www/boca/src/privatedirectory, does not contains a file namedwebcast.allUsers.zipand/orwebcast.allUsers.lockand/or a folder namedwebcast.allUsers. If exists, remove them.rm webcast.allUsers.zip rm webcast.allUsers.lock rm webcast.allUsers/ -r
Installing Animeitor
The "Animeitor" is stored at a public GitHub repository. To install him, you have to install Docker on the system.
- First of all, install Docker:
sudo apt-get update sudo apt-get install ca-certificates curl sudo install -m 0755 -d /etc/apt/keyrings sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc sudo chmod a+r /etc/apt/keyrings/docker.ascecho \ "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ sudo tee /etc/apt/sources.list.d/docker.list > /dev/null sudo apt-get up
