commit 57148fd905cd80afc97992d3c0668fb3499eb967 Author: DeathByDenim Date: Mon Jan 31 20:37:32 2022 -0500 Initial commit diff --git a/configs/supertuxkart.xml b/configs/supertuxkart.xml new file mode 100644 index 0000000..75be701 --- /dev/null +++ b/configs/supertuxkart.xml @@ -0,0 +1,170 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..629bd78 --- /dev/null +++ b/deploy.sh @@ -0,0 +1,62 @@ +#!/bin/bash + +### Deploy script for a game server running multiple open-source game servers +### This script is intended for Debian 11, but may work on other apt-based +### systems too + +set -e + +export stk_version="1.3" +export bzflag_version="2.4" +export mindustry_version="135" +export openhv_version="20220102" +export teeworlds_version="0.7.5" +export unvanquished_version="0.52.1" +export xonotic_version="0.8.2" + +export systemuser="onfoss" + +# Install what we need +apt update -y && apt full-upgrade -y +apt install --assume-yes \ + git tmux unzip curl vim openjdk-11-jdk xz-utils python3-venv python3-pip \ + python3-dev apt virtualenv python3-virtualenv libjpeg-dev zlib1g-dev \ + fuse hedgewars g++ gcc curl firewalld automake autoconf libtool \ + libcurl3-dev libc-ares-dev zlib1g-dev libncurses-dev make python3-aiohttp \ + nginx-core certbot python3-certbot-nginx sudo + +# Create the user for running the game servers +if ! getent passwd ${systemuser}; then + useradd ${systemuser} --system --create-home --shell=/bin/false +fi +export systemuserhome="$( getent passwd "${systemuser}" | cut -d: -f6 )" + +# Install the web interface for servers that require interactive shells +if [ -d console2web ]; then + cd console2web + git pull + cd - +else + git clone https://github.com/DeathByDenim/console2web.git +fi +cp console2web/console2web.py /usr/bin/console2web + +# Deploy the game servers +$(dirname "$0")/scripts/deploy_supertuxkart.sh +$(dirname "$0")/scripts/deploy_bzflag.sh +$(dirname "$0")/scripts/deploy_hedgewars.sh +$(dirname "$0")/scripts/deploy_mindustry.sh +$(dirname "$0")/scripts/deploy_openhv.sh +$(dirname "$0")/scripts/deploy_openspades.sh +$(dirname "$0")/scripts/deploy_teeworlds.sh +$(dirname "$0")/scripts/deploy_unvanguished.sh +$(dirname "$0")/scripts/deploy_xonotic.sh + +# Web dashboard +systemctl enable --now nginx + +firewall-cmd --zone=public --add-service=http --permanent +firewall-cmd --zone=public --add-service=https --permanent +firewall-cmd --reload + +certbot -n --nginx -d ${LINODE_ID} -d www.${LINODE_ID} --agree-tos -m jarno@jarno.ca diff --git a/scripts/deploy_bzflag.sh b/scripts/deploy_bzflag.sh new file mode 100755 index 0000000..207e9f7 --- /dev/null +++ b/scripts/deploy_bzflag.sh @@ -0,0 +1,39 @@ +#!/bin/bash +set -e + +# Install BZFlag +mkdir -p ${TMPDIR:-/tmp}/bzflag-build +cd ${TMPDIR:-/tmp}/bzflag-build +git clone --branch ${bzflag_version} https://github.com/BZFlag-Dev/bzflag.git +cd bzflag +./autogen.sh +./configure --disable-client --prefix=/opt/bzflag-${bzflag_version} +make +make install +if [ -L /usr/games/bzfs ]; then + ln -s /opt/bzflag-2.4/bin/bzfs /usr/games/ +fi + +rm -rf ${TMPDIR:-/tmp}/bzflag-build + +# Create SystemD unit +cat > /etc/systemd/system/bzflag.service < /etc/systemd/system/hedgewars.service < /opt/mindustry-v${mindustry_version}/mindustry.jar +mkdir -p /var/lib/mindustry +chown -R ${systemuser} /var/lib/mindustry + +cat > /etc/systemd/system/mindustry.service < /opt/openhv-${openhv_version}/OpenHV-x86_64.AppImage +chmod +x /opt/openhv-${openhv_version}/OpenHV-x86_64.AppImage + +cat > /etc/systemd/system/openhv.service < /etc/systemd/system/openspades.service < /etc/supertuxkart.xml + +# Add firewall rules +firewall-cmd --zone=public --add-port=2757/udp --permanent +firewall-cmd --zone=public --add-port=2759/udp --permanent + +# Configuration +cp $(dirname $0)/../config/supertuxkart.xml /etc/supertuxkart.xml + +# Create SystemD unit +cat > /etc/systemd/system/supertuxkart.service < /etc/teeworlds.cfg < /etc/systemd/system/teeworlds.service < ${TMPDIR:-/tmp}/unvanquished.zip +unzip -o -f -d ${TMPDIR:-/tmp} ${TMPDIR:-/tmp}/unvanquished.zip +mkdir -p ${unvanquished_directory}/bin ${unvanquished_directory}/share +unzip -o -f -d ${unvanquished_directory}/bin ${TMPDIR:-/tmp}/unvanquished*/linux-amd64.zip +if [ -d ${unvanquished_directory}/share/pkg ]; then + rm -rf ${unvanquished_directory}/share/pkg +fi +mv ${TMPDIR:-/tmp}/unvanquished*/pkg ${unvanquished_directory}/share +rm -rf ${TMPDIR:-/tmp}/unvanquished* + +mkdir -p ${systemuserhome}/unvanguished_home/config +cat > ${systemuserhome}/unvanguished_home/config/unvanguished.cfg < /etc/systemd/system/unvanguished.service < ${TMPDIR:-/tmp}/xonotic.zip +mkdir -p "${xonotic_directory}" +unzip -f -o -d ${xonotic_directory} ${TMPDIR:-/tmp}/xonotic.zip +rm -f ${TMPDIR:-/tmp}/xonotic.zip + +cat > /etc/xonotic.cfg < /etc/systemd/system/xonoto.service <