2022-02-01 02:37:32 +01:00
|
|
|
#!/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
|
2022-02-06 20:54:40 +01:00
|
|
|
###
|
|
|
|
### Specify domain name:
|
2022-02-15 01:13:57 +01:00
|
|
|
### DOMAINNAME=example.com HOSTEDBYNAME=DeathByDenim ./deploy.sh
|
2022-02-01 02:37:32 +01:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2022-02-09 01:39:31 +01:00
|
|
|
if [ -z $DOMAINNAME ]; then
|
2022-02-07 01:16:59 +01:00
|
|
|
echo "Domain name was not set. Please export DOMAINNAME first"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-02-15 01:13:57 +01:00
|
|
|
if [ -z $HOSTEDBYNAME ]; then
|
|
|
|
echo "Hosted-by name was not set. Please export HOSTEDBYNAME first"
|
|
|
|
exit 1
|
|
|
|
fi
|
2022-02-07 01:16:59 +01:00
|
|
|
|
2022-02-01 02:37:32 +01:00
|
|
|
export stk_version="1.3"
|
|
|
|
export bzflag_version="2.4"
|
|
|
|
export mindustry_version="135"
|
2022-02-24 00:39:54 +01:00
|
|
|
export openhv_version="20220221"
|
2022-02-01 02:37:32 +01:00
|
|
|
export teeworlds_version="0.7.5"
|
|
|
|
export unvanquished_version="0.52.1"
|
|
|
|
export xonotic_version="0.8.2"
|
2022-02-12 22:12:18 +01:00
|
|
|
export lix_version="0.9.41"
|
2022-02-01 02:37:32 +01:00
|
|
|
|
|
|
|
export systemuser="onfoss"
|
2022-02-06 20:54:40 +01:00
|
|
|
export letsencryptemail="jarno@jarno.ca"
|
2022-02-13 02:28:23 +01:00
|
|
|
|
|
|
|
# Store the randomly generated password. This is used for the web interface
|
|
|
|
# as well as for admin access for the game servers
|
2022-02-21 14:14:03 +01:00
|
|
|
if [ -f /etc/gameserverpassword ]; then
|
|
|
|
export systempassword=$(cat /etc/gameserverpassword)
|
|
|
|
else
|
|
|
|
export systempassword="$(< /dev/urandom tr -dc a-z | head -c${1:-8};echo;)"
|
|
|
|
echo "$systempassword" > /etc/gameserverpassword
|
|
|
|
chmod go= /etc/gameserverpassword
|
|
|
|
fi
|
2022-02-01 02:37:32 +01:00
|
|
|
|
|
|
|
# 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 \
|
2022-02-12 20:53:47 +01:00
|
|
|
fuse g++ gcc curl firewalld automake autoconf libtool \
|
2022-02-01 02:37:32 +01:00
|
|
|
libcurl3-dev libc-ares-dev zlib1g-dev libncurses-dev make python3-aiohttp \
|
2022-02-12 22:12:18 +01:00
|
|
|
nginx-core certbot python3-certbot-nginx sudo python3-psutil \
|
2022-02-13 21:10:59 +01:00
|
|
|
ldc dub libenet-dev python3-bcrypt
|
2022-02-01 02:37:32 +01:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
2022-02-19 01:00:02 +01:00
|
|
|
# Deploy web interface stuff
|
|
|
|
"$(dirname "$0")"/scripts/deploy_monitoring.sh
|
|
|
|
"$(dirname "$0")"/scripts/deploy_webserver.sh
|
|
|
|
|
2022-02-01 02:37:32 +01:00
|
|
|
# Deploy the game servers
|
2022-02-02 03:36:29 +01:00
|
|
|
"$(dirname "$0")"/scripts/deploy_supertuxkart.sh
|
|
|
|
"$(dirname "$0")"/scripts/deploy_bzflag.sh
|
|
|
|
"$(dirname "$0")"/scripts/deploy_hedgewars.sh
|
2022-02-12 22:12:18 +01:00
|
|
|
"$(dirname "$0")"/scripts/deploy_lix.sh
|
2022-02-02 03:36:29 +01:00
|
|
|
"$(dirname "$0")"/scripts/deploy_mindustry.sh
|
|
|
|
"$(dirname "$0")"/scripts/deploy_openhv.sh
|
|
|
|
"$(dirname "$0")"/scripts/deploy_openspades.sh
|
|
|
|
"$(dirname "$0")"/scripts/deploy_teeworlds.sh
|
2022-02-04 23:53:34 +01:00
|
|
|
"$(dirname "$0")"/scripts/deploy_unvanquished.sh
|
2022-02-02 03:36:29 +01:00
|
|
|
"$(dirname "$0")"/scripts/deploy_xonotic.sh
|
2022-02-19 23:15:30 +01:00
|
|
|
"$(dirname "$0")"/scripts/deploy_xonotic-br.sh
|
2022-02-18 22:15:37 +01:00
|
|
|
"$(dirname "$0")"/scripts/deploy_armagetron_advanced.sh
|
2022-02-07 02:34:02 +01:00
|
|
|
|
2022-02-20 15:54:17 +01:00
|
|
|
# Apply all pending firewall rules. NGINX shouldn't have to be restarted, but it seems to help.
|
2022-02-20 03:11:49 +01:00
|
|
|
firewall-cmd --reload
|
2022-02-20 15:54:17 +01:00
|
|
|
systemctl restart nginx
|
|
|
|
|
2022-02-13 02:28:23 +01:00
|
|
|
echo
|
|
|
|
echo "Installation complete. Password is ${systempassword}"
|