#!/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/opensoldat.service ]; then
systemctl stop opensoldat
fi
# Install dependencies
sudo apt-get -y install build-essential g++ cmake git fpc libprotobuf-dev protobuf-compiler libssl-dev libsdl2-dev libopenal-dev libphysfs-dev libfreetype6
# Install BZFlag
builddir=${TMPDIR:-/tmp}/opensoldat-build
mkdir -p ${builddir}
cd ${builddir}
if [ -d opensoldat ]; then
rm -rf opensoldat
fi
git clone https://github.com/opensoldat/opensoldat.git
git clone https://github.com/opensoldat/base.git
cd opensoldat
mkdir build && cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/opensoldat -DBUILD_CLIENT=False ..
make
make install
mkdir -p /opt/opensoldat/bin/configs /opt/opensoldat/bin/logs
cp -r ${builddir}/base/server/configs/bots /opt/opensoldat/bin/configs/bots
if ! [ -L /usr/games/opensoldatserver ]; then
ln -s /opt/opensoldat/bin/opensoldatserver /usr/games/
fi
rm -rf ${builddir}
cat > /opt/opensoldat/bin/configs/server_dm.cfg < /opt/opensoldat/bin/configs/server_ctf.cfg < /opt/opensoldat/bin/configs/mapslist.txt < /opt/opensoldat/bin/configs/mapslist_ctf.txt < /opt/opensoldat/bin/configs/mapslist_htf.txt < /opt/opensoldat/bin/configs/mapslist_inf.txt < /etc/systemd/system/opensoldat.service < /etc/systemd/system/opensoldat-monitor.service < /etc/nginx/gameserver.d/opensoldat.conf <