diff --git a/README.txt b/README.txt index 7bc854945a334105f840107169abb1afc09e4d58..519c18cc63a6a2e534b6cd94a976d73d6ec94081 100644 --- a/README.txt +++ b/README.txt @@ -1,25 +1,32 @@ -Davor: - credentials.json.template nach credentials.json kopieren - credentials.json anpassen +Scoreboard container +==================== - config.json mit cid anpassen +Configuration +------------- -Bauen: - docker build . -t scoreboard +* Copy file credentials.json.template to credentials.json +* Modify credentials in credentials.json +* Add correct cid in config.json -GUI in Docker nach aussen: - xhost +local:root - Wichtig: Nach dem Contest unbedingt xhost -local:root +Start - Easy way +---------------- -Run: (Insgesamt 3 Fenster!) +Execute the script ´´./start.sh´´ - it will build the container and start everything - 1. docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd)/config.json:/root/Carnifex/config.json -v $(pwd)/credentials.json:/root/Carnifex/credentials.json scoreboard +Start - Manual way +------------------ + +* Build with docker build . -t scoreboard +* Forward GUI to docker container: xhost +local:root (Do xhost -local:root after the contest) +* Run in 3 different windows + + 1. docker run -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd)/config.json:/root/Carnifex/config.json -v $(pwd)/credentials.json:/root/Carnifex/credentials.json --name scoreboard_container scoreboard -> python3 proxy.py - 2. docker exec -it $(docker ps -q -l) bash + 2. docker exec -it scoreboard_container bash cd ../Carnifex; ./server - 3. docker exec -it $(docker ps -q -l) bash + 3. docker exec -it scoreboard_container bash cd ../Carnifex; ./client diff --git a/start.sh b/start.sh new file mode 100755 index 0000000000000000000000000000000000000000..13ea21a2a2f31e06eca7463a662eef255b4a119c --- /dev/null +++ b/start.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +set -eu + +function die { + echo $1 + exit 1 +} + + +term=xterm + +if ! (which $term) ; then + die "xterm is not installed. Install it or modify this script to use a terminal which is installed." +fi + +# add the user in the docker group +if ! (groups | grep -qw "docker"); then + die "You must be in the docker group to execute this script" +fi + +# Add credentials in a file "credentials.json", use the template file for this. + +if [[ ! -f credentials.json ]]; then + die "credentials.json does not exist" +fi + +if grep -qw "change" credentials.json ; then + die "Credentials in credentials.json were not modified" +fi + +# Modify the cid to match the contest running + +if [[ ! -f config.json ]]; then + die "config.json does not exist" +fi + +if grep -qw "cid\": \"-1" config.json ; then + die "Config id \"cid\" was not mofied" +fi + +xhost +local:root + +# build the container +docker build . -t scoreboard + +# Start and run the container and execute carniprox, starts a new terminal-emulator with shell +$term -e "docker run --rm -it -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v $(pwd)/config.json:/root/Carnifex/config.json -v $(pwd)/credentials.json:/root/Carnifex/credentials.json --name scoreboard_container scoreboard python3 proxy.py" & +c1=$! + +# Wait until proxy is started +sleep 3 + +$term -e "docker exec -it --workdir /root/Carnifex scoreboard_container ./server" & +c2=$! + +# Wait until carnifex server is started +sleep 3 + +$term -e "docker exec -it --workdir /root/Carnifex -it scoreboard_container ./client" & +c3=$! + +wait $c1 $c2 $c3 + +docker rm -f scoreboard_container || true + +xhost -local:root