Skip to content
This repository has been archived by the owner on Sep 22, 2020. It is now read-only.

Installation

Christian Voigt edited this page Mar 31, 2020 · 18 revisions

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/pve_cw pve_cw
sudo passwd pve_cw

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

pve_cw ALL=(ALL:ALL) NOPASSWD:ALL

sudo chmod 0440 /etc/sudoers.d/pve_cw

Making it look good (optional)

sudo cp /root/.bashrc /opt/pve_cw
sudo chown pve_cw:pve_cw /opt/pve_cw/.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

pve_cw:x:1000:1000:PvE Chrani World Administrator:/opt/pve_cw:/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

Becoming our user

su - pve_cw

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

mkdir -p 7dtd_a18
./steamcmd/steamcmd.sh

login anonymous
force_install_dir /opt/pve_cw/7dtd_a18
app_update 294420 validate
quit

Creating a folder for the logs, savedgames and configs

mkdir -p 7dtd_a18_UserData 7dtd_a18_SaveGames 7dtd_a18_Logs

Copying standard config

cp 7dtd_a18/serverconfig.xml 7dtd_a18_SaveGames/pve_cw_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/pve_cw_xxxxxxxx.xml

<property name="TelnetPort" value="26902"/> <property name="TelnetPassword" value="supersecret"/>
<property name="AdminFileName" value="pve_cw_admin.xml"/>
<property name="UserDataFolder" value="/opt/pve_cw/7dtd_a18_UserData" />
<property name="SaveGameFolder" value="/opt/pve_cw/7dtd_a18_SaveGames" />
<property name="GameName" value="pve_cw_xxxxxxxx" />

start an independend session for our stuff

tmux new-session -s pve_cw

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

Installing the chrani-bot-tng!

Clone the sourcecode

git clone https://github.com/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

chrani-bot-tng/bot/options/module_telnet.json

{
"host": "127.0.0.1",
"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

chrani-bot-tng/bot/options/module_webserver.json

{
"host": "YOUR PUBLIC SERVER IP",
"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/pve_cw/7dtd_a18_SaveGames/pve_cw_xxxxxxxx.xml

Start the chrani-bot-tng

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

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

CTRL+b followed by d -> exit tmux

exit our gameserver environment

exit

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

tmux attach

Adding crash-recovery

nano -w 7dtd_a18/startserver_loop.sh

#!/bin/bash
export LD_LIBRARY_PATH=/opt/pve_cw/7dtd_a18

count=1
printf "%s\n\n" "starting infinite serverloop"

while true
do
printf "%s\n\n" "current-loop = $count"
7dtd_a18/7DaysToDieServer.x86_64 -logfile /opt/pve_cw/7dtd_a18_Logs/pve_cw_xxxxxxxx_`date +%Y-%m-%d_%H-%M-%S`.txt -quit -batchmode -nographics -dedicated -configfile=/opt/pve_cw/7dtd_a18_SaveGames/pve_cw_xxxxxxxx.xml
printf "%s\n\n" "waiting for server to settle down"
sleep 10
count=$((count + 1))
done

Start the dedicated server with crash-recovery

7dtd_a18/startserver_loop.sh

Monitor

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