minetest-mm/setup-mt

132 lines
6 KiB
Text
Raw Normal View History

2020-10-25 09:02:21 +01:00
#!/bin/bash
2020-10-25 09:34:23 +01:00
source config-file
2020-10-25 09:02:21 +01:00
2020-10-25 12:32:14 +01:00
if [ $first_install = "y" ]; then
2020-10-25 09:02:21 +01:00
echo "Create minetest user"
useradd minetest
2020-10-25 09:02:21 +01:00
mkdir -p /home/minetest/.minetest
echo "Allow sources repo and install dependecies for build"
perl -pi.orig -0e 's/^(deb .*\n)# (deb-src)/$1$2/mg' /etc/apt/sources.list
apt update
apt-get build-dep minetest -y
2020-10-25 12:32:14 +01:00
fi
2020-10-25 09:02:21 +01:00
echo "Compile libspatialindex"
rm -rf /tmp/spatialindex
git clone https://github.com/libspatialindex/libspatialindex /tmp/spatialindex
cd /tmp/spatialindex
cmake . -DCMAKE_INSTALL_PREFIX=/usr
2020-10-25 09:34:23 +01:00
make -j$(nproc)
2020-10-25 09:02:21 +01:00
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
2020-10-25 09:34:23 +01:00
make -j$(nproc)
2020-10-25 09:02:21 +01:00
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
2020-10-25 12:32:14 +01:00
if [ $first_install = "y" ]; then
echo "Configuring firstinstall config"
2020-10-25 09:02:21 +01:00
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
2020-10-25 10:53:07 +01:00
apt install postgresql postgresql-contrib -y
pg_ctlcluster 12 main start
sudo -u postgres createuser minetest
sudo -u postgres createdb minetest
sudo -u postgres createdb minetest_players
sudo -u postgres createdb minetest_auth
sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password '$psql_postgres_user_password';"
sudo -u postgres psql -U postgres -d postgres -c "alter user minetest with password '$psql_minetest_user_password';"
2020-10-25 11:01:45 +01:00
sudo -u postgres psql -U postgres -d postgres -c "grant all privileges on database "minetest" to minetest;"
sudo -u postgres psql -U postgres -d postgres -c "grant all privileges on database "minetest_players" to minetest;"
sudo -u postgres psql -U postgres -d postgres -c "grant all privileges on database "minetest_auth" to minetest;"
2020-10-25 10:53:07 +01:00
2020-10-25 11:01:45 +01:00
mkdir -p /home/minetest/.minetest/worlds/world/
2020-10-25 10:53:07 +01:00
echo "gameid = minetest" > /home/minetest/.minetest/worlds/world/world.mt
echo "backend = postgresql" >> /home/minetest/.minetest/worlds/world/world.mt
echo "creative_mode = false" >> /home/minetest/.minetest/worlds/world/world.mt
echo "enable_damage = true" >> /home/minetest/.minetest/worlds/world/world.mt
echo "player_backend = postgresql" >> /home/minetest/.minetest/worlds/world/world.mt
echo "auth_backend = postgresql" >> /home/minetest/.minetest/worlds/world/world.mt
echo "pgsql_connection = host=127.0.0.1 user=minetest password=$psql_minetest_user_password dbname=minetest" >> /home/minetest/.minetest/worlds/world/world.mt
echo "pgsql_player_connection = host=127.0.0.1 user=minetest password=$psql_minetest_user_password dbname=minetest_players" >> /home/minetest/.minetest/worlds/world/world.mt
echo "pgsql_auth_connection = host=127.0.0.1 user=minetest password=$psql_minetest_user_password dbname=minetest_auth" >> /home/minetest/.minetest/worlds/world/world.mt
2020-10-25 11:50:32 +01:00
echo "disable_fire = true" >> /home/minetest/.minetest/minetest.conf
echo "disable_tnt = true" >> /home/minetest/.minetest/minetest.conf
echo "server_name = "$mt_server_name"" >> /home/minetest/.minetest/minetest.conf
echo "server_description = "$mt_server_description"" >> /home/minetest/.minetest/minetest.conf
echo "server_address = "$mt_server_address"" >> /home/minetest/.minetest/minetest.conf
echo "server_url = "$mt_server_url"" >> /home/minetest/.minetest/minetest.conf
echo "server_announce = "$mt_server_announce"" >> /home/minetest/.minetest/minetest.conf
echo "ipv6_server = "$mt_ipv6_server"" >> /home/minetest/.minetest/minetest.conf
echo "default_game = minetest" >> /home/minetest/.minetest/minetest.conf
echo "motd = "$mt_motd"" >> /home/minetest/.minetest/minetest.conf
echo "max_users = "$mt_max_users"" >> /home/minetest/.minetest/minetest.conf
echo "name = "$mt_admin"" >> /home/minetest/.minetest/minetest.conf
echo "language = "$mt_language"" >> /home/minetest/.minetest/minetest.conf
echo "port = "$mt_port"" >> /home/minetest/.minetest/minetest.conf
echo "enable_rollback_recording = "$mt_enable_rollback_recording"" >> /home/minetest/.minetest/minetest.conf
echo "default_privs = "$mt_default_privs"" >> /home/minetest/.minetest/minetest.conf
2020-10-25 12:15:26 +01:00
2020-10-25 11:01:45 +01:00
echo "Fix privileges on /home/minetest"
chown minetest:minetest /home/minetest/ -cR
2020-10-25 11:50:32 +01:00
if [ $ufw_enable = "y" ]; then
2020-10-25 12:15:26 +01:00
apt install ufw -y
ufw allow proto tcp to any port $ufw_ssh_port_for_accept
ufw allow proto udp to any port $mt_port
ufw enable
2020-10-25 11:50:32 +01:00
fi
2020-10-25 10:53:07 +01:00
fi
2020-10-25 09:02:21 +01:00
systemctl start minetestsrv
systemctl enable minetestsrv