2022-02-01 02:37:32 +01:00
|
|
|
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
|
2022-02-06 19:04:33 +01:00
|
|
|
if [ -e /etc/systemd/system/bzflag.service ]; then
|
|
|
|
systemctl stop bzflag
|
|
|
|
fi
|
|
|
|
|
2022-02-01 02:37:32 +01:00
|
|
|
# Install BZFlag
|
|
|
|
mkdir -p ${TMPDIR:-/tmp}/bzflag-build
|
|
|
|
cd ${TMPDIR:-/tmp}/bzflag-build
|
2022-02-06 19:04:33 +01:00
|
|
|
if [ -d bzflag ]; then
|
|
|
|
rm -rf bzflag
|
|
|
|
fi
|
2022-02-01 02:37:32 +01:00
|
|
|
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
|
2022-02-06 19:04:33 +01:00
|
|
|
if ! [ -L /usr/games/bzfs ]; then
|
2022-07-31 16:01:52 +02:00
|
|
|
ln -s /opt/bzflag-${bzflag_version}/bin/bzfs /usr/games/
|
2022-02-01 02:37:32 +01:00
|
|
|
fi
|
2022-08-12 17:25:10 +02:00
|
|
|
if ! [ -L /usr/games/bzadmin ]; then
|
|
|
|
ln -s /opt/bzflag-${bzflag_version}/bin/bzadmin /usr/games/
|
|
|
|
fi
|
2022-02-01 02:37:32 +01:00
|
|
|
|
|
|
|
rm -rf ${TMPDIR:-/tmp}/bzflag-build
|
|
|
|
|
|
|
|
# Create SystemD unit
|
|
|
|
cat > /etc/systemd/system/bzflag.service <<EOF
|
|
|
|
[Unit]
|
|
|
|
Description=BZFlag server
|
|
|
|
After=network.target
|
2022-08-07 20:26:56 +02:00
|
|
|
Requires=bzflag-monitor.service
|
2022-02-01 02:37:32 +01:00
|
|
|
|
|
|
|
[Service]
|
2022-02-13 02:28:23 +01:00
|
|
|
ExecStart=/usr/games/bzfs -ms 5 -j -t +r +f SW +f SB{2} +f GM +f ST{3} -d -d -d -passwd "${systempassword}"
|
2022-02-01 02:37:32 +01:00
|
|
|
Restart=on-failure
|
|
|
|
User=${systemuser}
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
|
2022-08-07 20:26:56 +02:00
|
|
|
# Create SystemD unit
|
|
|
|
cat > /etc/systemd/system/bzflag-monitor.service <<EOF
|
|
|
|
[Unit]
|
|
|
|
Description=BZFlag server monitor
|
|
|
|
After=bzflag.service
|
|
|
|
Requires=bzflag.service
|
|
|
|
|
|
|
|
[Service]
|
2022-08-12 21:17:52 +02:00
|
|
|
ExecStart=/usr/bin/console2web -a "${systempassword}" -p 62553 /usr/games/bzadmin admin@localhost -ui stdboth "/password ${systempassword}"
|
2022-08-07 20:26:56 +02:00
|
|
|
Restart=on-failure
|
|
|
|
User=${systemuser}
|
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|
|
|
|
EOF
|
|
|
|
|
2022-02-01 02:37:32 +01:00
|
|
|
systemctl daemon-reload
|
|
|
|
systemctl enable --now bzflag.service
|
|
|
|
|
2022-08-07 20:26:56 +02:00
|
|
|
cat > /etc/nginx/gameserver.d/bzflag.conf <<EOF
|
|
|
|
location /bzflag {
|
|
|
|
proxy_pass http://localhost:62553/;
|
|
|
|
proxy_http_version 1.1;
|
|
|
|
proxy_set_header Upgrade \$http_upgrade;
|
|
|
|
proxy_set_header Connection "Upgrade";
|
|
|
|
proxy_set_header Host \$host;
|
|
|
|
}
|
|
|
|
EOF
|
|
|
|
|
2022-02-01 02:37:32 +01:00
|
|
|
# Add firewall rules
|
|
|
|
firewall-cmd --zone=public --add-port=5154/tcp --permanent
|
|
|
|
firewall-cmd --zone=public --add-port=5154-5200/udp --permanent
|