diff --git a/.env.sample b/.env.sample new file mode 100644 index 0000000..f2905cf --- /dev/null +++ b/.env.sample @@ -0,0 +1,15 @@ +# eBot configuration +EBOT_IP=127.0.0.1 +LOG_ADDRESS_SERVER=http://127.0.0.1:12345 +EBOT_ADMIN_LOGIN=admin +EBOT_ADMIN_PASSWORD=admin +EBOT_ADMIN_EMAIL=admin@admin +WEBSOCKET_SECRET_KEY=strongpassword +COMMAND_STOP_DISABLED=true + +# Database configuration +MYSQL_USER=ebotv3 +MYSQL_DATABASE=ebotv3 +MYSQL_PASSWORD=strongpassword +MYSQL_ROOT_PASSWORD=strongpassword + diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0f2b378 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +.env.bak +data/ +*.bak +.env diff --git a/README.md b/README.md index b08f241..ff1e40f 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,9 @@ It is a containerized version of eBot, which is a full managed server-bot writte ## How to run it You should download the repository content, place it in a folder, and then execute the following commands in the specified order: ``` +cp .env.sample .env +chmod a+x setup.sh configure.sh +./setup.sh docker-compose build docker-compose up ``` @@ -24,4 +27,4 @@ To improve security, you should set the web socket secret key in two specific co For the web service, go the etc/eBotWeb directory and open the app_user.yml file. Inside this file, locate the WEBSOCKET_SECRET_KEY parameter and replace its value with a strong and unique secret key -For the socket service, navigate to the etc/eBotSocket directory and open the config.ini file. Within this file, find the websocket_secret_key property and update its value with the same key used for the web service. \ No newline at end of file +For the socket service, navigate to the etc/eBotSocket directory and open the config.ini file. Within this file, find the websocket_secret_key property and update its value with the same key used for the web service. diff --git a/configure.sh b/configure.sh new file mode 100755 index 0000000..835c3e0 --- /dev/null +++ b/configure.sh @@ -0,0 +1,53 @@ +#!/usr/bin/env bash + +red='\e[1;31m%s\e[0m\n' +green='\e[1;32m%s\e[0m\n' +yellow='\e[1;33m%s\e[0m\n' +blue='\e[1;34m%s\e[0m\n' +magenta='\e[1;35m%s\e[0m\n' +cyan='\e[1;36m%s\e[0m\n' + +printf "$green" "eBot configuration script" + +# eBot configuration +EBOT_IP=10.10.10.91 +LOG_ADDRESS_SERVER=http://10.10.10.91:12345 +EBOT_ADMIN_LOGIN=admin +EBOT_ADMIN_PASSWORD=admin +EBOT_ADMIN_EMAIL=admin@tset.com +WEBSOCKET_SECRET_KEY=f0ad422482332a9a9a4fbcfaaa65a696 +COMMAND_STOP_DISABLED=true + +# Database configuration +MYSQL_USER=ebotv3 +MYSQL_DATABASE=ebotv3 +MYSQL_PASSWORD=a3368dabb311bb66540e9bb9030714e7 +MYSQL_ROOT_PASSWORD=501e0a10b2702be5350915784ad2aca1 + +source .env +echo "Patching ./etc/eBotSocket/config.ini" +cp ./etc/eBotSocket/config.ini ./etc/eBotSocket/config.ini.bak +sed -i "s/MYSQL_IP =.*/MYSQL_IP = \"mysqldb\"/g" ./etc/eBotSocket/config.ini +sed -i "s/MYSQL_PASS =.*/MYSQL_PASS = \"$MYSQL_PASSWORD\"/g" ./etc/eBotSocket/config.ini +sed -i "s/MYSQL_BASE =.*/MYSQL_BASE = \"$MYSQL_DATABASE\"/g" ./etc/eBotSocket/config.ini +sed -i "s/MYSQL_BASE =.*/MYSQL_BASE = \"$MYSQL_DATABASE\"/g" ./etc/eBotSocket/config.ini +sed -i "s/COMMAND_STOP_DISABLED =.*/COMMAND_STOP_DISABLED = $COMMAND_STOP_DISABLED/g" ./etc/eBotSocket/config.ini +sed -i "s#LOG_ADDRESS_SERVER =.*#LOG_ADDRESS_SERVER = \"$LOG_ADDRESS_SERVER\"#g" ./etc/eBotSocket/config.ini +sed -i "s/WEBSOCKET_SECRET_KEY =.*/WEBSOCKET_SECRET_KEY = \"$WEBSOCKET_SECRET_KEY\"/g" ./etc/eBotSocket/config.ini +sed -i "s/REDIS_HOST =.*/REDIS_HOST = \"redis\"/g" ./etc/eBotSocket/config.ini +sed -i "s/BOT_IP =.*/BOT_IP = \"0.0.0.0\"/g" ./etc/eBotSocket/config.ini + + +echo "Patching ./etc/eBotWeb/app_user.yml" +cp ./etc/eBotWeb/app_user.yml ./etc/eBotWeb/app_user.yml.bak +sed -i "s|log_match:.*|log_match: /app/ebot-logs/log_match|" ./etc/eBotWeb/app_user.yml +sed -i "s|log_match_admin:.*|log_match_admin: /app/ebot-logs/log_match_admin|" ./etc/eBotWeb/app_user.yml +sed -i "s|demo_path:.*|demo_path: /app/ebot-demos|" ./etc/eBotWeb/app_user.yml +sed -i "s|websocket_secret_key:.*|websocket_secret_key: $WEBSOCKET_SECRET_KEY|" ./etc/eBotWeb/app_user.yml +sed -i "s|ebot_ip:.*|ebot_ip: $EBOT_IP|g" ./etc/eBotWeb/app_user.yml + +echo "Patching ./etc/eBotWeb/database.yml" +cp ./etc/eBotWeb/databases.yml ./etc/eBotWeb/databases.yml.bak +sed -i "s|dsn:.*|dsn: \"mysql:host=mysqldb;dbname=${MYSQL_DATABASE}\"|" ./etc/eBotWeb/databases.yml +sed -i "s|username:.*|username: ${MYSQL_USER}|" ./etc/eBotWeb/databases.yml +sed -i "s|password:.*|password: ${MYSQL_PASSWORD}|" ./etc/eBotWeb/databases.yml diff --git a/docker-compose.yml b/docker-compose.yml index bc667d4..5871b03 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,28 +1,36 @@ version: '3' services: - ebotweb: + ebot-web: build: - context: ./ebotweb + context: ./ebot-web + environment: + - EBOT_ADMIN_LOGIN + - EBOT_ADMIN_PASSWORD + - EBOT_ADMIN_EMAIL volumes: - "eBotWebVolume:/app/eBot-CSGO-Web" + - "./ebot-logs:/app/ebot-logs" + - "./ebot-demos:/app/ebot-demos" - "./etc/eBotWeb/app_user.yml:/app/eBot-CSGO-Web/config/app_user.yml" - "./etc/eBotWeb/databases.yml:/app/eBot-CSGO-Web/config/databases.yml" depends_on: - mysqldb - ebotsocket: + ebot-socket: build: - context: ./ebotsocket + context: ./ebot-socket ports: - "12360:12360" volumes: + - "./ebot-logs:/app/eBot-CSGO/logs" + - "./ebot-demos:/app/eBot-CSGO/demos" - "./etc/eBotSocket/config.ini:/app/eBot-CSGO/config/config.ini" depends_on: - mysqldb - - ebotweb + - ebot-web - redis - ebotlogreceiver: + ebot-logs-receiver: build: - context: ./ebotlogreceiver + context: ./ebot-logs-receiver ports: - "12345:12345" volumes: @@ -33,10 +41,10 @@ services: image: biarms/mysql:5.7 restart: always environment: - - MYSQL_DATABASE=ebotv3 - - MYSQL_ROOT_PASSWORD=7w£6GfV0z92 - - MYSQL_USER=ebotv3 - - MYSQL_PASSWORD=7w£6GfV0z92 + - MYSQL_DATABASE + - MYSQL_ROOT_PASSWORD + - MYSQL_USER + - MYSQL_PASSWORD volumes: - "./data/db/mysql:/var/lib/mysql" redis: @@ -54,7 +62,7 @@ services: - "443:443" restart: always depends_on: - - ebotweb + - ebot-web - mysqldb volumes: eBotWebVolume: diff --git a/ebot-demos/.gitignore b/ebot-demos/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/ebotlogreceiver/Dockerfile b/ebot-logs-receiver/Dockerfile similarity index 100% rename from ebotlogreceiver/Dockerfile rename to ebot-logs-receiver/Dockerfile diff --git a/ebot-logs/.gitignore b/ebot-logs/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/ebot-logs/log_match/.gitignore b/ebot-logs/log_match/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/ebot-logs/log_match_admin/.gitignore b/ebot-logs/log_match_admin/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/ebotsocket/Dockerfile b/ebot-socket/Dockerfile similarity index 100% rename from ebotsocket/Dockerfile rename to ebot-socket/Dockerfile diff --git a/ebotsocket/setup.sh b/ebot-socket/setup.sh similarity index 100% rename from ebotsocket/setup.sh rename to ebot-socket/setup.sh diff --git a/ebotweb/Dockerfile b/ebot-web/Dockerfile similarity index 100% rename from ebotweb/Dockerfile rename to ebot-web/Dockerfile diff --git a/ebotweb/setup.sh b/ebot-web/setup.sh similarity index 74% rename from ebotweb/setup.sh rename to ebot-web/setup.sh index 5822fc2..21cc3db 100644 --- a/ebotweb/setup.sh +++ b/ebot-web/setup.sh @@ -10,14 +10,14 @@ if [ ! -f .installed ]; then cp -n -R temp/* eBot-CSGO-Web && rm -rf temp cd eBot-CSGO-Web - + sleep 30 - + php symfony cc php symfony doctrine:build --all --no-confirmation - php symfony guard:create-user --is-super-admin admin@ebot admin admin + php symfony guard:create-user --is-super-admin $EBOT_ADMIN_EMAIL $EBOT_ADMIN_LOGIN $EBOT_ADMIN_PASSWORD rm -rf web/installation @@ -28,5 +28,9 @@ if [ ! -f .installed ]; then php-fpm else echo "eBot Web is already installed. Skipping setup." + cd eBot-CSGO-Web + php symfony cc + echo "Clearing cache" + php-fpm fi diff --git a/etc/eBotLogReceiver/config.json b/etc/eBotLogReceiver/config.json index 2093578..f31cfb0 100644 --- a/etc/eBotLogReceiver/config.json +++ b/etc/eBotLogReceiver/config.json @@ -32,14 +32,6 @@ "path": "logs", "split": true } - }, - { - "path": "src/logs-receiver/plugins/mapper.ts", - "config": { - "mapping": { - "127.0.0.1:27015": "192.168.0.1:27015" - } - } } ] - } \ No newline at end of file + } diff --git a/etc/eBotSocket/config.ini b/etc/eBotSocket/config.ini index a08e4ef..4b15c41 100644 --- a/etc/eBotSocket/config.ini +++ b/etc/eBotSocket/config.ini @@ -8,11 +8,11 @@ MYSQL_IP = "mysqldb" MYSQL_PORT = "3306" MYSQL_USER = "ebotv3" -MYSQL_PASS = "7w£6GfV0z92" +MYSQL_PASS = "5bbcb2cb12525f00d608b38b187f55fa" MYSQL_BASE = "ebotv3" [Config] -BOT_IP = "0.0.0.0" ; leave it as is (Docker) +BOT_IP = "0.0.0.0" BOT_PORT = 12360 SSL_ENABLED = false SSL_CERTIFICATE_PATH = "ssl/cert.pem" @@ -23,8 +23,8 @@ DELAY_BUSY_SERVER = 120 NB_MAX_MATCHS = 0 PAUSE_METHOD = "nextRound" ; nextRound or instantConfirm or instantNoConfirm NODE_STARTUP_METHOD = "node" ; binary file name or none in case you are starting it with forever or manually -LOG_ADDRESS_SERVER = "http://127.0.0.1:12345" ; change the address to your extenral one -WEBSOCKET_SECRET_KEY = "helloworld" +LOG_ADDRESS_SERVER = "http://10.10.10.91:12345" +WEBSOCKET_SECRET_KEY = "f6c106f706d2ce59a136c509c1e2f1a1" [Redis] REDIS_HOST = "redis" @@ -57,4 +57,4 @@ MAP[] = "de_anubis" [Settings] COMMAND_STOP_DISABLED = true RECORD_METHOD = "matchstart" ; matchstart or knifestart -DELAY_READY = true \ No newline at end of file +DELAY_READY = true diff --git a/etc/eBotWeb/app_user.yml b/etc/eBotWeb/app_user.yml index f624cb9..bfe4518 100644 --- a/etc/eBotWeb/app_user.yml +++ b/etc/eBotWeb/app_user.yml @@ -2,11 +2,11 @@ # white space are VERY important, don't remove it or it will not work # ---------------------------------------------------------------------- - log_match: ../../ebot-csgo/logs/log_match - log_match_admin: ../../ebot-csgo/logs/log_match_admin - demo_path: ../../ebot-csgo/demos + log_match: /app/ebot-logs/log_match + log_match_admin: /app/ebot-logs/log_match_admin + demo_path: /app/ebot-demos - default_max_round: 15 + default_max_round: 12 default_rules: rules default_overtime_max_round: 3 default_overtime_startmoney: 16000 @@ -16,7 +16,7 @@ demo_download: true - ebot_ip: 127.0.0.1 # Change to your external IP + ebot_ip: 127.0.0.1 ebot_port: 12360 # lan or net, it's to display the server IP or the GO TV IP @@ -33,4 +33,4 @@ toornament_plugin_key: test-123457890 # Same as eBot config - websocket_secret_key: helloworld + websocket_secret_key: f6c106f706d2ce59a136c509c1e2f1a1 diff --git a/etc/eBotWeb/databases.yml b/etc/eBotWeb/databases.yml index 2a01b5b..e15c8d7 100644 --- a/etc/eBotWeb/databases.yml +++ b/etc/eBotWeb/databases.yml @@ -5,6 +5,6 @@ all: doctrine: class: sfDoctrineDatabase param: - dsn: mysql:host=mysqldb;dbname=ebotv3 + dsn: "mysql:host=mysqldb;dbname=ebotv3" username: ebotv3 - password: 7w£6GfV0z92 + password: 5bbcb2cb12525f00d608b38b187f55fa diff --git a/etc/nginx/default.conf b/etc/nginx/default.conf index b125c82..1f6b3e2 100644 --- a/etc/nginx/default.conf +++ b/etc/nginx/default.conf @@ -20,7 +20,7 @@ server { fastcgi_param HTTPS off; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param SCRIPT_NAME $fastcgi_script_name; - fastcgi_pass eBotWeb:9000; + fastcgi_pass ebot-web:9000; fastcgi_read_timeout 120; } @@ -31,4 +31,4 @@ server { error_log /var/log/nginx/project_error.log; access_log /var/log/nginx/project_access.log; -} \ No newline at end of file +} diff --git a/setup.sh b/setup.sh new file mode 100755 index 0000000..05ad04a --- /dev/null +++ b/setup.sh @@ -0,0 +1,100 @@ +#!/usr/bin/env bash + +red='\e[1;31m%s\e[0m\n' +green='\e[1;32m%s\e[0m\n' +yellow='\e[1;33m%s\e[0m\n' +blue='\e[1;34m%s\e[0m\n' +magenta='\e[1;35m%s\e[0m\n' +cyan='\e[1;36m%s\e[0m\n' + +function yesNo() { + while true; do + read -p "$1 [y/n]: " yn + case $yn in + [Yy]* ) return 0;; + [Nn]* ) return 1;; + * ) echo "Please answer yes or no.";; + esac + done +} + +function ask_with_default() { + local prompt="$1" + local default_value="$2" + + read -p "${prompt} [current: ${default_value}]: " input_value + if [[ -z "$input_value" ]]; then + echo "$default_value" + else + echo "$input_value" + fi +} + + +printf "$green" "eBot setup script" +printf "This script will only configure the .env file. You must run or accept to run the ./configure.sh\r\n" + + +if yesNo "Would you like to fresh the configs files by downloading recent configuration from github (main branch) ?" +then + wget https://raw.githubusercontent.com/deStrO/eBot-CSGO-Web/master/config/app_user.yml.default -O ./etc/eBotWeb/app_user.yml + wget https://raw.githubusercontent.com/deStrO/eBot-CSGO-Web/master/config/databases.yml -O ./etc/eBotWeb/databases.yml + wget https://raw.githubusercontent.com/deStrO/eBot-CSGO/master/config/config.ini.smp -O ./etc/eBotSocket/config.ini +fi + +function generatePassword() { + openssl rand -hex 16 +} + +cp .env .env.bak +if yesNo "Would you like generate a new random websocket secrets ?" +then + NEW_WEBSOCKET_SECRET_KEY=$(generatePassword) + sed -i -e "s#WEBSOCKET_SECRET_KEY=.*#WEBSOCKET_SECRET_KEY=${NEW_WEBSOCKET_SECRET_KEY}#g" \ + "$(dirname "$0")/.env" +fi + +if yesNo "Would you like generate new mysql random password " +then + NEW_MYSQL_ROOT_PASSWORD=$(generatePassword) + NEW_MYSQL_PASSWORD=$(generatePassword) + sed -i -e "s#MYSQL_ROOT_PASSWORD=.*#MYSQL_ROOT_PASSWORD=${NEW_MYSQL_ROOT_PASSWORD}#g" \ + -e "s#MYSQL_PASSWORD=.*#MYSQL_PASSWORD=${NEW_MYSQL_PASSWORD}#g" \ + "$(dirname "$0")/.env" +fi + +source .env + +printf "$green" "Now doing the default configuration of eBot web" + +EBOT_ADMIN_LOGIN=$(ask_with_default "eBot Web login" $EBOT_ADMIN_LOGIN) +EBOT_ADMIN_PASSWORD=$(ask_with_default "eBot Web password" $EBOT_ADMIN_PASSWORD) +EBOT_ADMIN_EMAIL=$(ask_with_default "eBot Web email" $EBOT_ADMIN_EMAIL) + +sed -i -e "s#EBOT_ADMIN_LOGIN=.*#EBOT_ADMIN_LOGIN=${EBOT_ADMIN_LOGIN}#g" \ + -e "s#EBOT_ADMIN_PASSWORD=.*#EBOT_ADMIN_PASSWORD=${EBOT_ADMIN_PASSWORD}#g" \ + -e "s#EBOT_ADMIN_EMAIL=.*#EBOT_ADMIN_EMAIL=${EBOT_ADMIN_EMAIL}#g" \ + "$(dirname "$0")/.env" + +printf "$green" "Now configuring IP & logs receiver" +echo "Before going further, you need to understand the concept with the new system of logs" +echo "The CS2 server will send the logs via HTTP to the logs-receiver" +echo "This log receiver is exposed by docker on port 12345 by default" +echo "On the next question, you will have to give the full web address of the logger, that have to be reachable from the server" +echo "If your ip is 123.123.123.123, you must fill http://123.123.123.123:12345" +LOG_ADDRESS_SERVER=$(ask_with_default "Log address server" $LOG_ADDRESS_SERVER) + +sed -i -e "s#LOG_ADDRESS_SERVER=.*#LOG_ADDRESS_SERVER=${LOG_ADDRESS_SERVER}#g" \ + "$(dirname "$0")/.env" + +echo "Now, for the web part, we need to know on which IP the server will run, please fill in the IP of the server (public or lan) (format 123.123.123.123)" +echo "You won't be able to connect to the websocket server for realtime updates if you don't give us the right IP." + +EBOT_IP=$(ask_with_default "Log address server" $EBOT_IP) +sed -i -e "s#EBOT_IP=.*#EBOT_IP=${EBOT_IP}#g" \ + "$(dirname "$0")/.env" + +if yesNo "Would you like regenerate all configuration files ?" +then + ./configure.sh +fi