9 Installation
Christian Voigt 於 1 周之前 修改了此頁面

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 Chrani World 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_a18

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

mkdir -p 7dtd_a18_UserData 7dtd_a18_SaveGames 7dtd_a18_Logs
cp 7dtd_a18/serverconfig.xml 7dtd_a18_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_a18

Start the dedicated server

7dtd_a18/startserver.sh -configfile=/opt/bot_test/7dtd_a18_SaveGames/bot_test_xxxxxxxx.xml

Start the chrani-bot-tng

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

python /opt/bot_test/chrani-bot-tng/app.py

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

nano -w 7dtd_a18/startserver_loop.sh


date=date +%Y-%m-%d_%H-%M-%S

export LD_LIBRARY_PATH=${homedir}/${gamedir}

parameters=”-quit -batchmode -nographics -dedicated”

cd ${gamedir}
printf “%s\n\n” “starting infinite serverloop for ${title} on ${date}”

while true
printf “%s\n\n” “current-loop=${count}”
./7DaysToDieServer.x86_64 -logfile ${logfile} -configfile=${configfile} ${parameters}
printf “%s\n\n” “waiting for server to settle down”
sleep 10
count=$((count + 1))

cd ..

Make it executable

chmod +x 7dtd_a18/startserver_loop.sh

Start the dedicated server with crash-recovery



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_a18_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)"