CS:GO Game Server One-Click

by linode
7 deployments · 5 still active · last rev. 2 days ago

Compatible with: Debian 9
						#!/bin/bash
#
#<UDF name="pubkey" Label="SSH public key" example="ssh-rsa..." default="" />
#<UDF name="gslt" label="Steam token" example="Steam gameserver token. Needed to list as public server." />
#<UDF name="autoteambalance" label="autoteambalance" default="1" />
#<UDF name="roundtime" label="roundtime" default="5" />
#<UDF name="maxrounds" label="maxrounds" default="10" />
#<UDF name="buyanywhere" label="buyanywhere" default="0" />
#<UDF name="friendlyfire" label="friendlyfire" default="0" />
#<UDF name="motd" label="motd" default="Powered by Linode!" />

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

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

GAMESERVER="csgoserver"

set_hostname
apt_setup_update

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

# CSGO 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
sudo 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

# Install linuxGSM
linuxgsm_install

# Install CSGO
game_install

# Setup crons and create systemd service file
service_config

#Game Config Options

touch /home/csgoserver/serverfiles/csgo/cfg/server.cfg
echo "mp_autoteambalance $AUTOTEAMBALANCE" >> /home/csgoserver/serverfiles/csgo/cfg/server.cfg
echo "mp_roundtime $ROUNDTIME" >> /home/csgoserver/serverfiles/csgo/cfg/server.cfg
echo "mp_maxrounds $MAXROUNDS" >> /home/csgoserver/serverfiles/csgo/cfg/server.cfg
echo "mp_buy_anywhere $BUYANYWHERE" >> /home/csgoserver/serverfiles/csgo/cfg/server.cfg
echo "mp_friendlyfire $FRIENDLYFIRE" >> /home/csgoserver/serverfiles/csgo/cfg/server.cfg
echo "$MOTD" > /home/csgoserver/serverfiles/csgo/motd.txt

chown csgoserver:csgoserver /home/csgoserver/serverfiles/csgo/cfg/server.cfg

# Start the service and setup firewall
ufw_install
ufw allow 27015
ufw allow 27020/udp
ufw allow 27005/udp
ufw enable
fail2ban_install
systemctl start "$GAMESERVER".service
systemctl enable "$GAMESERVER".service
stackscript_cleanup