From 91477d33b729361d3b7a7fc8f22571a430776199 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 25 Oct 2020 13:07:02 +0100 Subject: [PATCH] add_reset_scripts --- reset-all | 40 ++++++++++++++++++++++++++++++++++++++++ reset-map | 14 ++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 reset-all create mode 100644 reset-map diff --git a/reset-all b/reset-all new file mode 100644 index 00000000..065a05d1 --- /dev/null +++ b/reset-all @@ -0,0 +1,40 @@ +#!/bin/bash +source config-file + +echo "Stop minetestsrv service" +systemctl stop minetestsrv + +echo "Drop and recreate all databases" +sudo -u postgres dropdb minetest +sudo -u postgres dropdb minetest_players +sudo -u postgres dropdb minetest_auth +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';" + +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;" + +echo "Backup configs" +mv -f /home/minetest/.minetest/minetest.conf /tmp/minetest.conf +mv -f /home/minetest/.minetest/worlds/world/world.mt /tmp/world.mt + +rm -rf /home/minetest + +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 "Restore configs" +mv -f /tmp/minetest.conf /home/minetest/.minetest/minetest.conf +mv -f /tmp/world.mt /home/minetest/.minetest/worlds/world/world.mt + +echo "Fix privileges on /home/minetest" +chown minetest:minetest /home/minetest/ -cR + +echo "Start minetestsrv service" +systemctl start minetestsrv diff --git a/reset-map b/reset-map new file mode 100644 index 00000000..1ee6b0d4 --- /dev/null +++ b/reset-map @@ -0,0 +1,14 @@ +#!/bin/bash +source config-file + +echo "Stop minetestsrv service" +systemctl stop minetestsrv + +echo "Drop and recreate map database" +sudo -u postgres dropdb minetest +sudo -u postgres createdb minetest +sudo -u postgres psql -U postgres -d postgres -c "alter user minetest with password '$psql_minetest_user_password';" +sudo -u postgres psql -U postgres -d postgres -c "grant all privileges on database "minetest" to minetest;" + +echo "Start minetestsrv service" +systemctl start minetestsrv