2022-02-01 02:37:32 +01:00
|
|
|
#!/bin/sh
|
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/>.
|
|
|
|
|
|
|
|
set -e
|
2022-02-01 02:37:32 +01:00
|
|
|
|
|
|
|
echo "Installing SuperTuxKart ${stk_version}"
|
|
|
|
|
2022-02-06 19:07:04 +01:00
|
|
|
if [ -e /etc/systemd/system/supertuxkart.service ]; then
|
|
|
|
systemctl stop supertuxkart
|
|
|
|
fi
|
|
|
|
|
2022-07-31 16:01:52 +02:00
|
|
|
if [ -z ${stk_version} ] || [ "${stk_version}" = "latest" ]; then
|
|
|
|
stk_version=$(curl -s https://api.github.com/repos/supertuxkart/stk-code/releases/latest | jq -r '.["tag_name"]')
|
|
|
|
fi
|
|
|
|
|
2022-02-01 02:37:32 +01:00
|
|
|
# Install SuperTuxKart
|
|
|
|
stk_dir="/opt/SuperTuxKart-${stk_version}"
|
|
|
|
mkdir -p ${stk_dir}
|
2022-11-20 17:58:04 +01:00
|
|
|
curl --location "https://github.com/supertuxkart/stk-code/releases/download/${stk_version}/SuperTuxKart-${stk_version}-linux-x86_64.tar.xz" | tar --extract --xz --no-same-owner --strip-components=1 --directory=${stk_dir}
|
2022-02-01 02:37:32 +01:00
|
|
|
ln -s ${stk_dir}/bin/supertuxkart /usr/games/supertuxkart
|
|
|
|
|
|
|
|
# Configuration
|
2022-03-20 00:59:13 +01:00
|
|
|
cp $(dirname $0)/../configs/supertuxkart.xml /etc/supertuxkart.xml
|
2022-02-01 02:37:32 +01:00
|
|
|
|
|
|
|
# Create SystemD unit
|
|
|
|
cat > /etc/systemd/system/supertuxkart.service <<EOF
|
|
|
|
[Unit]
|
|
|
|
Description=SuperTuxKart server
|
|
|
|
After=network.target
|
|
|
|
|
|
|
|
[Service]
|
|
|
|
ExecStart=${stk_dir}/run_game.sh --server-config=/etc/supertuxkart.xml --lan-server=onFOSS
|
|
|
|
Restart=on-failure
|
|
|
|
User=${systemuser}
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
|
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl enable --now supertuxkart.service
|
2022-02-24 13:01:21 +01:00
|
|
|
|
2022-07-31 16:01:52 +02:00
|
|
|
# Add firewall rules
|
2022-02-24 13:01:21 +01:00
|
|
|
firewall-cmd --zone=public --add-port=2757/udp --permanent
|
2022-07-31 16:01:52 +02:00
|
|
|
firewall-cmd --zone=public --add-port=2759/udp --permanent
|