minetest-mm/setup-mt

68 lines
2.5 KiB
Text
Raw Normal View History

2020-10-25 09:02:21 +01:00
#!/bin/bash
source "${BASH_SOURCE%/*}/config-file"
echo "Create minetest user"
adduser minetest
mkdir -p /home/minetest/.minetest
echo "Compile libspatialindex"
rm -rf /tmp/spatialindex
git clone https://github.com/libspatialindex/libspatialindex /tmp/spatialindex
cd /tmp/spatialindex
cmake . -DCMAKE_INSTALL_PREFIX=/usr
make
make install
echo "Compile minetest version $mt_version"
rm -rf /tmp/minetest
git clone --depth 1 --branch "$mt_version" https://github.com/minetest/minetest.git /tmp/minetest
cp -n /tmp/minetest/minetest.conf.example /home/minetest/.minetest/minetest.conf
cd /tmp/minetest
cmake . \
-DBUILD_CLIENT=0 \
-DBUILD_SERVER=1 \
-DCMAKE_INSTALL_PREFIX=/usr \
-DCUSTOM_BINDIR=/usr/bin \
-DCUSTOM_DOCDIR="/usr/share/doc/minetest" \
-DCUSTOM_SHAREDIR="/usr/share/minetest" \
-DENABLE_CURL=1 \
-DENABLE_LEVELDB=1 \
-DENABLE_LUAJIT=1 \
-DENABLE_REDIS=1 \
-DENABLE_SOUND=0 \
-DENABLE_SYSTEM_GMP=1 \
-DENABLE_POSTGRESQL=1 \
-DPOSTGRESQL_CONFIG_EXECUTABLE=/usr/bin/pg_config \
-DPOSTGRESQL_LIBRARY=/usr/lib/libpq.so \
-DRUN_IN_PLACE=0
make
echo "Stop minetestsrv service(upgrade case)"
systemctl stop minetestsrv
make install
echo "Clone minetest_game $mt_version"
mkdir -p /home/minetest/.minetest/games/
rm -rf /home/minetest/.minetest/games/minetest
git clone --depth 1 --branch "$mt_version" https://github.com/minetest/minetest_game.git /home/minetest/.minetest/games/minetest
echo "Fix privileges on /home/minetest"
chown minetest:minetest /home/minetest/ -cR
echo "Creating minetestsrv systemd service"
echo "[Unit]" > /etc/systemd/system/minetestsrv.service
echo "Description=MinetestSRV" >> /etc/systemd/system/minetestsrv.service
echo "After=postgresql.service" >> /etc/systemd/system/minetestsrv.service
echo "[Service]" >> /etc/systemd/system/minetestsrv.service
echo "Type=simple" >> /etc/systemd/system/minetestsrv.service
echo "User=minetest" >> /etc/systemd/system/minetestsrv.service
echo "Group=minetest" >> /etc/systemd/system/minetestsrv.service
echo "ExecStart=/usr/bin/minetestserver" >> /etc/systemd/system/minetestsrv.service
echo "Restart=always" >> /etc/systemd/system/minetestsrv.service
echo "RestartSec=3" >> /etc/systemd/system/minetestsrv.service
echo "[Install]" >> /etc/systemd/system/minetestsrv.service
echo "WantedBy=multi-user.target" >> /etc/systemd/system/minetestsrv.service
systemctl daemon-reload
systemctl start minetestsrv
systemctl enable minetestsrv