Skip to content

YusukeKato/ShellgeiOnlineJudge

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SHELLGEI ONLINE JUDGE

Shell one-liner playground: https://shellgei-online-judge.com/

  • client: html + js + css ( + nginx)
  • server: php + python ( + docker)
  • data: problem text files
  • scripts: deploy & test

Table of Contents

Reference

Setup

  • Ubuntu 24.04 LTS (+WSL2)
  • Ubuntu 22.04 LTS
  • Amazon Linux 2023

Install nginx

execute the following command:

sudo apt update && sudo apt -y upgrade
# sudo dnf update && sudo dnf upgrade

# install nginx
sudo apt -y install nginx

# install php
# sudo apt -y install php

# install php-fpm
sudo apt -y install php-fpm

Config nginx

execute the following command:

# edit config
sudo vim /etc/nginx/conf.d/default.conf
# or
sudo vim /etc/nginx/sites-available/default

Update as follows:

# example: php8.1-fpm
location ~ \.php$ {
  fastcgi_pass unix:/run/php/php8.1-fpm.sock;
  fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
  # WSL2(Ubuntu 24.04 LTS): fastcgi_param SCRIPT_FILENAME <root_path>$fastcgi_script_name;
  # ex: fastcgi_param SCRIPT_FILENAME /var/www/html/$fastcgi_script_name;
  include fastcgi_params;
}

Install Docker

execute the following command:

# install docker
sudo apt update && sudo apt -y upgrade
sudo apt install ca-certificates curl gnupg lsb-release
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt update
sudo apt install docker-ce docker-ce-cli containerd.io docker-compose-plugin

# setup
sudo gpasswd -a $USER docker
sudo systemctl restart docker

# download image file
docker pull theoldmoon0602/shellgeibot

Execution user

Change the execution user from nginx to www-data in WSL.

# example: 8.3
sudo vim /etc/php/8.3/fpm/pool.d/www.conf
sudo vim /etc/nginx/nginx.conf

Permissions to execute Docker

execute the following command:

sudo visudo

Add the following line to the end.

# the username that executes PHP: www-data
# which docker: /usr/bin/docker
www-data ALL=(ALL) NOPASSWD: /usr/bin/docker

Start Nginx

execute the following command:

sudo systemctl restart nginx
# sudo systemctl status nginx
# sudo systemctl start nginx
# sudo systemctl stop nginx

Deploy

  • usr: /usr/share/nginx/html/
  • var: /var/www/html

execute the following command:

cd scripts
# `usr`
./deploy.bash usr server
# `var`
./deploy.bash var server

# local
./deploy.bash usr local
# or
./deploy.bash var local

Test

execute the following command:

cd scripts
# server
python3 test.py server
# local test
python3 test.py local

Maintenance

Output log

cat root_path/shellgei_log.txt | tail -n 20

Update image file

docker pull theoldmoon0602/shellgeibot

Update Ubuntu

sudo apt update
sudo apt upgrade

Update Amazon Linux

sudo dnf update
sudo dnf upgrade

Update Let's Encrypt

sudo certbot certonly --standalone
sudo systemctl reload nginx

Appendix

How to use SSH

# sudo chmod 400 example.pem
ssh -i "example.pem" [email protected]

License

  • License file
  • data: Creative Commons BY-NC-ND 4.0
  • client, server, scripts: Apache License 2.0