16 Installation
Christian Voigt a édité cette page il y a 10 mois

Install the chrani-bot-tng + 7dtd game-server complete edition

Taking care of users

we will create a new user for the bot and the gameserver, creating their own home-directory and adding them to the sudoers group, then taking steps to make the shell look good (optional)!

sudo useradd -m -d /opt/bot_test bot_test
sudo passwd bot_test

sudo nano -w /etc/sudoers.d/bot_test


sudo chmod 0440 /etc/sudoers.d/bot_test

Making it look good (optional)

sudo cp /root/.bashrc /opt/bot_test
sudo chown bot_test:bot_test /opt/bot_test/.bashrc

If it ain't looking good now, you might need to add the standard shell to your /etc/passwd file. Find your user and take care that it ends like this one:

sudo nano -w /etc/passwd

bot_test:x:1000:1000:PvE Server Administrator:/opt/bot_test:/bin/bash

Installing the 7dtd Gameserver

we will become our new user, download steamcmd, create a directory for it, not arguing if it already exists (-p) and then extract steamcmd into it. we will then remove the steamcmd archive

su - bot_test

Installing steamcmd

wget http://media.steampowered.com/installer/steamcmd_linux.tar.gz
mkdir -p steamcmd && tar xvzf steamcmd_linux.tar.gz -C ./steamcmd/
rm steamcmd_linux.tar.gz

Installing the dedicated server (this is also how to update it!)

mkdir -p 7dtd_a19

login anonymous
force_install_dir /opt/bot_test/7dtd_a19
app_update 294420 validate or app_update 294420 -beta latest_experimental

mkdir -p 7dtd_a19_UserData 7dtd_a19_SaveGames 7dtd_a19_Logs
cp 7dtd_a19/serverconfig.xml 7dtd_a19_SaveGames/bot_test_xxxxxxxx.xml

Making required config adjustments

GameName must NOT contain any spaces! The bot will not work correctly with spaces in GameName

nano -w 7dtd_a18_SaveGames/bot_test_xxxxxxxx.xml

start an independend session for our stuff

tmux new-session -s bot_test

CTRL+b followed by , -> rename current window to chrani-bot-tng

Installing the chrani-bot-tng!

Clone the sourcecode

git clone https://code.chrani.net/wwevo/chrani-bot-tng.git
cd chrani-bot-tng && git pull origin development && cd ..

Setting up the python 3.7.x environment

python -m venv cb-tng-venv
source cb-tng-venv/bin/activate

pip install --upgrade pip
pip install -r chrani-bot-tng/requirements.txt

setting up the telnet component (minimum settings for 7dtd)

host would be your IP address, or if the bot is on the same machine, localhost
port + password is what you have set up in your 7dtd serverconfig


"host": "",
"port": 26902,
"password": "supersecret"

You might want to set the telnet buffer to a higher value if you have a high-pop server or are using mods like Darkness Falls. the standard 16k is too small for extensive amount of entities

"max_telnet_buffer": 32768

setting up the webserver component

host would be your servers public IP address port and secret-key can be whatever you feel is clever


"port": 26905,
"Flask_secret_key": "whateverisclever"

With those two files in place and some sensible data to populate them, the bot should start up and provide it's webinterface and should start listening to the games telnet.

Making things Go!

Creating required shells

CTRL+b followed by c -> creates new window CTRL+b followed by w -> opens window selection select the new window

CTRL+b followed by , -> rename window to 7dtd_a19

Start the dedicated server

7dtd_a19/startserver.sh -configfile=/opt/bot_test/7dtd_a19_SaveGames/bot_test_xxxxxxxx.xml

Start the chrani-bot-tng

CTRL+b followed by w -> opens window selection select chrani-bot-tng window

##### using default options:
python /opt/bot_test/chrani-bot-tng/app.py

##### using custom options:
python /opt/bot_test/chrani-bot-tng/app.py custom_options_foldername

CTRL+b followed by d -> exit tmux

exit our gameserver environment


To get back to our shell, all we have to do is to log in as our bot_test user and get tmux back with

tmux attach

Adding crash-recovery

cd 7dtd_a19  
wget https://code.chrani.net/chrani.net/chrani-bot-tng/wiki/startserver_loop.sh  
cd ..  

Make it executable

chmod +x 7dtd_a19/startserver_loop.sh  

Start the dedicated server with crash-recovery

7dtd_a19/startserver_loop.sh bot_test xxxxxxxx  


nothing much here for now. You could always open up another tmux window and run a tail on the latest logs

tail -f -- "$(find ./7dtd_a19_Logs/ -maxdepth 1 -type f -printf '%T@.%p\0' | sort -znr -t. -k1,2 | while IFS= read -r -d '' -r record ; do printf '%s' "$record" | cut -d. -f3- ; break ; done)"