TF2 CA

by agracie
4 deployments · 1 still active · last rev. 5 days ago

Compatible with: Debian 9
						#!/bin/bash
#
#<UDF name="pubkey" Label="SSH pubkey (installed for root and sudo user)?" example="ssh-rsa ..." />
#<UDF name="gslt" label="Steam token" example="Steam gameserver token. Needed to list as public server" default="" />
#<UDF name="motd" label="motd" default="Powered by Linode!" />
#<UDF name="autoteambalance" label="autoteambalance" default="0" />
#<UDF name="maxrounds" label="maxrounds" default="5" />
#<UDF name="timelimit" label="timelimit" default="35" />

source <ssinclude StackScriptID="349139">
source <ssinclude StackScriptID="370022">

GAMESERVER="tf2server"

exec 1> >(tee -a "/var/log/stackscript.log") 2>&1

set_hostname
apt_setup_update

if [[ "$PUBKEY" != "" ]]; then
  add_pubkey
fi

# Teamfortress2 specific dependencies
debconf-set-selections <<< "postfix postfix/main_mailer_type string 'No Configuration'"
debconf-set-selections <<< "postfix postfix/mailname string `hostname`"
dpkg --add-architecture i386
apt update
apt -q -y install mailutils postfix curl wget file \
bzip2 gzip unzip bsdmainutils python util-linux \
ca-certificates binutils bc jq tmux lib32gcc1 libstdc++6 \
libstdc++6:i386 libcurl4-gnutls-dev:i386 libtcmalloc-minimal4:i386

# Install linuxGSM
linuxgsm_install

# Install Teamfortress2
game_install

# Setup crons and create systemd service file
service_config

# Custom game configs
echo "// Config options" >> /home/tf2server/serverfiles/tf/cfg/tf2server.cfg
echo "mp_autoteambalance $AUTOTEAMBALANCE" >> /home/tf2server/serverfiles/tf/cfg/tf2server.cfg
echo "mp_maxrounds $MAXROUNDS" >> /home/tf2server/serverfiles/tf/cfg/tf2server.cfg
echo "mp_timelimit $TIMELIMIT" >> /home/tf2server/serverfiles/tf/cfg/tf2server.cfg
sed -i '1 a "$MOTD" /home/tf2server/serverfiles/cfg/motd_default.txt


# Start the service and setup firewall
ufw_install
ufw allow 27014:27050/tcp
ufw allow 3478:4380/udp
ufw allow 27000:27030/udp
ufw allow 26901
ufw enable
fail2ban_install
systemctl start "$GAMESERVER".service
systemctl enable "$GAMESERVER".service
stackscript_cleanup