This post is mostly for my own reference, feel free to contact me about the bot

This routine will run ONE instance of the bot. It will be started by a cron-job which is run every minute to enable crash-recovery and in-game shutdown/restart commands. This is in no way optimized or ready for production, it works well enough for development ^^

It is assumed that you have installed your 7dtd game with the chrani.net server setup guide!

Required packages


apt-get install git

apt-get install virtualenv

Create bot-user and home for the bot


mkdir -p /opt/7dtd-chrani-bot/app

useradd –comment “7dtd-chrani-bot – A 7days to Die Server-Bot” -d /opt/7dtd-chrani-bot -m -r -s /bin/bash -g sdtd 7dtd-chrani-bot

chown 7dtd-chrani-bot:sdtd -R /opt/7dtd-chrani-bot

mkdir /opt/7dtd-chrani-bot/venv_pypy

mkdir /tmp/cb
cd /tmp/cb

Download and configure the bot


git clone https://github.com/wwevo/7dtd-chrani-bot.git

cp 7dtd-chrani-bot/data/configurations/chrani-bot.json-example 7dtd-chrani-bot/data/configurations/your-bot.json

nano 7dtd-chrani-bot/data/configurations/your-bot.json

Enter all required data there. leave “ipinfo.io_password” empty if you don’t have an account there. We use it to blacklist IP’s for example.

cp 7dtd-chrani-bot/example-bot.sh 7dtd-chrani-bot/your-bot.json

Edit this file according to your needs

Move the files to their new home


cp -R 7dtd-chrani-bot/* /opt/7dtd-chrani-bot/app/.
chown 7dtd-chrani-bot:sdtd -R /opt/7dtd-chrani-bot

Download and install pypy


This is only for ubuntu 16.04, for general installation consult the official page about it

Create the venv for pypy


cd /opt

wget https://bitbucket.org/pypy/pypy/downloads/pypy2-v6.0.0-linux64.tar.bz2

tar xf pypy2-v6.0.0-linux64.tar.bz2

rm pypy2-v6.0.0-linux64.tar.bz2

ln -s /opt/pypy2-v6.0.0-linux64/bin/pypy /usr/local/bin/pypy (optional)

virtualenv -p /opt/pypy2-v6.0.0-linux64/bin/pypy /opt/7dtd-chrani-bot/venv_pypy

Configure the pypy environment


source /opt/7dtd-chrani-bot/venv_pypy/bin/activate

pip install -U pip wheel

pip install -r /opt/7dtd-chrani-bot/app/requirements.txt

Make the bot immortal


export VISUAL=nano; crontab -u 7dtd-chrani-bot -e
*/1 * * * * sh /opt/7dtd-chrani-bot/app/your-bot.sh

Update bot code


as bot user run

cd /opt/7dtd-chrani-bot/app
git pull

To restart the whole bot after a code-change / update, use the following chat command in game or shut down the bot manually

/shut down the matrix

The bot should be restarted with the new code by the cron-job. While this isn’t optimal, it works well enough for development purposes ^^