Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herodrigues/f9ec0f85ef32be4e3f7036b229b64f9e to your computer and use it in GitHub Desktop.
Save herodrigues/f9ec0f85ef32be4e3f7036b229b64f9e to your computer and use it in GitHub Desktop.
BOCA Online Contest Administrator installation tutorial

Installing BOCA Online Contest Administrator

Requirements

The system was tested with:

  • postgresql 9.4
  • apache 2.2
  • php 5.6

Note: The symbol $ means that you have to execute the commands in a terminal

Installation

Usually that is true if you have installed the following Ubuntu/Debian packages, as given by an apt-get example line:

$ sudo apt-get install postgresql postgresql-contrib postgresql-client apache2 
$ sudo apt-get install libapache2-mod-php5 php5 php5-cli php5-cgi php5-gd php5-mcrypt php5-pgsql

Configuration

Create the file /etc/apache2/conf-enabled/boca.conf

<Directory /var/www/html/boca>
       AllowOverride Options AuthConfig Limit
       Order Allow,Deny
       Allow from all
       AddDefaultCharset utf-8
</Directory>
<Directory /var/www/html/boca/src/private>
       AllowOverride None
       Deny from all
</Directory>
<Directory /var/www/html/boca/doc>
       AllowOverride None
       Deny from all
</Directory>
<Directory /var/www/html/boca/tools>
       AllowOverride None
       Deny from all
</Directory>

Create the file /etc/postgresql/*/main/postgresql.conf, where * is your postgresql version number (e.g. 9.4)

tcpip_socket = true #if using tcp to connect to database (older postgresqls)
listen_addresses = '*' #newer postgresqls

# THE FOLLOWING MAY BE GOOD FOR PERFORMANCE
max_connections = 100
maintenance_work_mem = 32MB 
shared_buffers = 512MB      ## USE AROUND 1/3 OF YOUR RAM
work_mem = 10MB
effective_cache_size = 512MB     ## USE AROUND 1/3 OF YOUR RAM

Steps for installing BOCA:

  • Download BOCA here and unpack it into a internet world readable directory, according to the setting you chose in /etc/apache2/conf-enabled/boca.conf
$ cd /var/www/html
$ tar xvzf boca-x.y.z.tar.gz
$ ln -s boca-x.y.z boca

x.y.z is the BOCA version you just downloaded it

  • Set the postgres password
$ sudo -u postgres psql
ALTER USER postgres WITH PASSWORD 'your_password';
\q
  • Create a postgresql account with permission to create new databases
$ psql -h 127.0.0.1 -U postgres -d template1
template1=# create user bocauser with password 'boca' createdb;
template1=# \q
  • Edit the file src/private/conf.php (placed where you unpacked boca), in order to set up the correct values for your system. E.g.
  $conf["dblocal"]="false"; // use unix socket to connect?
  $conf["dbhost"]="localhost"; // ip address of the db
  $conf["dbname"]="bocadb"; // name of the boca database
  $conf["dbuser"]="bocauser"; // unpriviligied boca user
  $conf["dbpass"]="boca";     // unpriviligied boca password
  $conf["dbsuperuser"]="bocauser"; // priviligied boca user
  $conf["dbsuperpass"]="boca";	   // priviligied boca password
       // note that it is just fine to use the same user for
       // unpriv and priv access

  // secret key to be used in HTTP headers
  // you MUST set it with any random large enough sequence
  // DONT LEAVE IT AS YOU GOT WHEN UNPACKED THE SOFTWARE
  // CHOOSE ANOTHER NUMBER/STRING AND REPLACE BELOW
  $conf["key"]="secretKey:23894091237589234759234723489";
  
  // initial password that is used for the user admin -- set it
  // to something hard to guess if the server is available
  // online even in the moment you are creating the contest
  // In this way, the new accounts for system and admin that are
  // eventually created come already with the password set to this
  // value. It is your task later to update these passwords to
  // some other values within the BOCA web interface.
  $conf["basepass"]="boca";

  // the following field is used by the autojudging script
  // set it with IP address (or other short description)
  // of the computer allocated for
  // autojudging during the competition
  // this is only useful for debug purposes when multiple 
  // autojudges are being used
  $conf["ip"]='local';
  • Run the php script to initialize the boca database. E.g.
$ cd /var/www/html/boca/src
$ sudo php private/createdb.php
  • Check your lsb-release
$ cat /etc/lsb-release

You should get something like:

DISTRIB_CODENAME=jessie

If you get nothing, install and check lsb-release:

$ sudo apt-get install lsb-release
$ lsb-release -da

You should get something similar to this

No LSB modules are available.
Distributor ID:	Debian
Description:	Debian GNU/Linux 8.4 (jessie)
Release:	8.4
Codename:	jessie

Then, create the file /etc/lsb-release and put the line DISTRIB_CODENAME=codename, where codename is the distro codename you got in the the previous step.

  • Create the bocajail enviroment
$ sudo apt-get install quota debootstrap schroot
$ cd /var/www/html/boca/tools/etc/icpc
$ sudo ./createbocajail.sh

This will take several minutes. After that, it's all done. Now you have to manage the contest with a browser and boca. Proceed to the ADMIN.TXT file.

@diemesleno
Copy link

Qual a finalidade do bocajail?

Digo isso pois até antes da criação do bocajail, o sistema Boca funciona normalmente. Pelo menos no acesso ao sistema com o usuário system, e premitindo a criação de competições.

Após a criação do bocajail ao reiniciar a máquina a mesma não inicia mais. Parando em erros de incialização.

@herodrigues
Copy link
Author

O bocajail impede que os usuários tentem rodar códigos maliciosos durante uma competição, mas ele não interfere na execução se você pular a instalação dele.

@648trindade
Copy link

Para o uso do autojudge o bocajail é obrigatório?

@herodrigues
Copy link
Author

@648trindade Sim, é necessário

@moisesguimaraes
Copy link

Tava pensando em fazer um Dockerfile ou Vagrantfile pra isso, alguém já deu esse passo?

@caflorezv
Copy link

Hi, I'm getting this error while running a script:

Decryption error -- contact an admin now ( getFunctionName decryptData)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment