#!/bin/bash
# Collection of scripts to deploy a server hosting several open-source games
# Copyright (C) 2022 Jarno van der Kolk
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see .
set -e
if [ -e /etc/systemd/system/bzflag.service ]; then
systemctl stop bzflag
fi
# Install BZFlag
mkdir -p ${TMPDIR:-/tmp}/bzflag-build
cd ${TMPDIR:-/tmp}/bzflag-build
if [ -d bzflag ]; then
rm -rf bzflag
fi
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-${bzflag_version}/bin/bzfs /usr/games/
fi
if ! [ -L /usr/games/bzadmin ]; then
ln -s /opt/bzflag-${bzflag_version}/bin/bzadmin /usr/games/
fi
rm -rf ${TMPDIR:-/tmp}/bzflag-build
# Create SystemD unit
cat > /etc/systemd/system/bzflag.service < /etc/systemd/system/bzflag-monitor.service < /etc/nginx/gameserver.d/bzflag.conf <