This repository has been archived on 2023-10-22. You can view files and clone it, but cannot push or open issues or pull requests.
gameserver/scripts/deploy_opensoldat.sh

233 lines
4.6 KiB
Bash
Raw Normal View History

2022-06-19 21:01:01 +02:00
#!/bin/bash
2022-08-20 14:36:21 +02:00
# 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 <https://www.gnu.org/licenses/>.
2022-06-19 21:01:01 +02:00
set -e
2022-07-10 19:01:03 +02:00
if [ -e /etc/systemd/system/opensoldat.service ]; then
systemctl stop opensoldat
2022-06-19 21:01:01 +02:00
fi
# Install dependencies
2022-07-01 14:56:02 +02:00
sudo apt-get -y install build-essential g++ cmake git fpc libprotobuf-dev protobuf-compiler libssl-dev libsdl2-dev libopenal-dev libphysfs-dev libfreetype6
2022-06-19 21:01:01 +02:00
# Install BZFlag
2022-07-10 19:01:03 +02:00
builddir=${TMPDIR:-/tmp}/opensoldat-build
2022-06-19 21:01:01 +02:00
mkdir -p ${builddir}
cd ${builddir}
2022-07-10 19:01:03 +02:00
if [ -d opensoldat ]; then
rm -rf opensoldat
2022-06-19 21:01:01 +02:00
fi
2022-07-06 02:42:55 +02:00
git clone https://github.com/opensoldat/opensoldat.git
git clone https://github.com/opensoldat/base.git
cd opensoldat
2022-06-19 21:01:01 +02:00
mkdir build && cd build
2022-08-13 23:21:33 +02:00
cmake -DCMAKE_INSTALL_PREFIX=/opt/opensoldat -DBUILD_CLIENT=False ..
2022-06-19 21:01:01 +02:00
make
make install
2022-07-10 19:01:03 +02:00
mkdir -p /opt/opensoldat/bin/configs
cp -r ${builddir}/base/server/configs/bots /opt/opensoldat/bin/configs/bots
2022-06-19 21:01:01 +02:00
2022-07-10 19:01:03 +02:00
if ! [ -L /usr/games/opensoldatserver ]; then
ln -s /opt/opensoldat/bin/opensoldatserver /usr/games/
2022-06-19 21:01:01 +02:00
fi
rm -rf ${builddir}
2022-07-10 19:01:03 +02:00
cat > /opt/opensoldat/bin/configs/server_dm.cfg <<EOF
2022-06-19 21:01:01 +02:00
sv_hostname "onFOSS LAN"
bots_random_alpha 0
sv_gamemode 0
sv_greeting "Welcome to the onFOSS LAN server"
sv_website ${DOMAINNAME}
bots_chat false
EOF
2022-07-10 19:01:03 +02:00
cat > /opt/opensoldat/bin/configs/server_ctf.cfg <<EOF
sv_hostname "onFOSS LAN"
bots_random_alpha 0
sv_gamemode 3
sv_greeting "Welcome to the onFOSS LAN server"
sv_website ${DOMAINNAME}
bots_chat false
sv_maplist "mapslist_ctf.txt"
EOF
2022-07-10 19:01:03 +02:00
if ! [ -L /opt/opensoldat/bin/configs/server.cfg ]; then
ln -s ./server_dm.cfg /opt/opensoldat/bin/configs/server.cfg
2022-07-06 02:42:55 +02:00
fi
2022-07-10 19:01:03 +02:00
cat > /opt/opensoldat/bin/configs/mapslist.txt <<EOF
2022-06-19 21:01:01 +02:00
Aero
Airpirates
Arena2
Arena3
Arena
Bigfalls
Blox
Bridge
Bunker
Cambodia
CrackedBoot
Daybreak
DesertWind
Factory
Flashback
HH
Island2k5
Jungle
Krab
Lagrange
Leaf
MrSnowman
RatCave
Rok
RR
Shau
Tropiccave
Unlim
Veoto
EOF
2022-07-10 19:01:03 +02:00
cat > /opt/opensoldat/bin/configs/mapslist_ctf.txt <<EOF
2022-06-19 21:01:01 +02:00
ctf_Aftermath
ctf_Amnesia
ctf_Ash
ctf_B2b
ctf_Blade
ctf_Campeche
ctf_Cobra
ctf_Crucifix
ctf_Death
ctf_Division
ctf_Dropdown
ctf_Equinox
ctf_Guardian
ctf_Hormone
ctf_IceBeam
ctf_Kampf
ctf_Lanubya
ctf_Laos
ctf_Mayapan
ctf_Maya
ctf_MFM
ctf_Nuubia
ctf_Raspberry
ctf_Rotten
ctf_Ruins
ctf_Run
ctf_Scorpion
ctf_Snakebite
ctf_Steel
ctf_Triumph
ctf_Viet
ctf_Voland
ctf_Wretch
ctf_X
EOF
2022-07-10 19:01:03 +02:00
cat > /opt/opensoldat/bin/configs/mapslist_htf.txt <<EOF
2022-06-19 21:01:01 +02:00
htf_Arch
htf_Baire
htf_Boxed
htf_Desert
htf_Dorothy
htf_Dusk
htf_Erbium
htf_Feast
htf_Mossy
htf_Muygen
htf_Niall
htf_Nuclear
htf_Prison
htf_Rubik
htf_Star
htf_Tower
htf_Void
htf_Vortex
htf_Zajacz
EOF
2022-07-10 19:01:03 +02:00
cat > /opt/opensoldat/bin/configs/mapslist_inf.txt <<EOF
2022-06-19 21:01:01 +02:00
inf_Abel
inf_April
inf_Argy
inf_Belltower
inf_Biologic
inf_Changeling
inf_Flute
inf_Fortress
inf_Industrial
inf_Messner
inf_Moonshine
inf_Motheaten
inf_Outpost
inf_Rescue
inf_Rise
inf_Warehouse
inf_Warlock
EOF
2022-07-10 19:01:03 +02:00
chown -R ${systemuser}: /opt/opensoldat/bin/configs
2022-06-19 21:01:01 +02:00
# Create SystemD unit
2022-07-10 19:01:03 +02:00
cat > /etc/systemd/system/opensoldat.service <<EOF
2022-06-19 21:01:01 +02:00
[Unit]
Description=Soldat server
After=network.target
2022-08-13 23:21:33 +02:00
Requires=opensoldat-monitor.service
2022-06-19 21:01:01 +02:00
[Service]
2022-07-10 19:01:03 +02:00
ExecStart=/usr/games/opensoldatserver -sv_adminpassword "${systempassword}"
2022-06-19 21:01:01 +02:00
Restart=on-failure
User=${systemuser}
[Install]
WantedBy=multi-user.target
EOF
2022-08-13 23:21:33 +02:00
cat > /etc/systemd/system/opensoldat-monitor.service <<EOF
[Unit]
Description=Soldat server monitor
After=network.target,opensoldat.service
Requires=opensoldat.service
[Service]
ExecStart=/usr/bin/console2web -a "${systempassword}" -p 62554 -b "${systempassword}" telnet localhost 23073
Restart=on-failure
User=${systemuser}
[Install]
WantedBy=multi-user.target
EOF
2022-06-19 21:01:01 +02:00
systemctl daemon-reload
2022-07-10 19:01:03 +02:00
systemctl enable --now opensoldat.service
2022-06-19 21:01:01 +02:00
2022-08-13 23:21:33 +02:00
cat > /etc/nginx/gameserver.d/opensoldat.conf <<EOF
location /opensoldat {
proxy_pass http://localhost:62554/;
proxy_http_version 1.1;
proxy_set_header Upgrade \$http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host \$host;
}
EOF
2022-06-19 21:01:01 +02:00
# Add firewall rules
firewall-cmd --zone=public --add-port=23073/udp --permanent
2022-07-01 18:39:33 +02:00
firewall-cmd --zone=public --add-port=23083/tcp --permanent