reset-all-world.mt-regenerate-from-config-file 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. source config-file
  3. echo "Stop minetestsrv service"
  4. systemctl stop minetestsrv
  5. echo "Drop and recreate all databases"
  6. sudo -u postgres dropdb minetest
  7. sudo -u postgres dropdb minetest_players
  8. sudo -u postgres dropdb minetest_auth
  9. sudo -u postgres createdb minetest
  10. sudo -u postgres createdb minetest_players
  11. sudo -u postgres createdb minetest_auth
  12. sudo -u postgres psql -U postgres -d postgres -c "alter user postgres with password '$psql_postgres_user_password';"
  13. sudo -u postgres psql -U postgres -d postgres -c "alter user minetest with password '$psql_minetest_user_password';"
  14. sudo -u postgres psql -U postgres -d postgres -c "grant all privileges on database "minetest" to minetest;"
  15. sudo -u postgres psql -U postgres -d postgres -c "grant all privileges on database "minetest_players" to minetest;"
  16. sudo -u postgres psql -U postgres -d postgres -c "grant all privileges on database "minetest_auth" to minetest;"
  17. echo "Backup minetest.conf"
  18. mv -f /home/minetest/.minetest/minetest.conf /tmp/minetest.conf
  19. echo "Remove /home/minetest"
  20. rm -rf /home/minetest
  21. echo "Clone minetest_game $mt_version"
  22. mkdir -p /home/minetest/.minetest/games/
  23. rm -rf /home/minetest/.minetest/games/minetest
  24. git clone --depth 1 --branch "$mt_version" https://github.com/minetest/minetest_game.git /home/minetest/.minetest/games/minetest
  25. echo "Restore minetest.conf and regenerate world.mt"
  26. mkdir -p /home/minetest/.minetest/worlds/world/
  27. mv -f /tmp/minetest.conf /home/minetest/.minetest/minetest.conf
  28. echo "gameid = minetest" > /home/minetest/.minetest/worlds/world/world.mt
  29. echo "backend = postgresql" >> /home/minetest/.minetest/worlds/world/world.mt
  30. echo "creative_mode = $mt_creative_mode" >> /home/minetest/.minetest/worlds/world/world.mt
  31. echo "enable_damage = true" >> /home/minetest/.minetest/worlds/world/world.mt
  32. echo "player_backend = postgresql" >> /home/minetest/.minetest/worlds/world/world.mt
  33. echo "auth_backend = postgresql" >> /home/minetest/.minetest/worlds/world/world.mt
  34. echo "pgsql_connection = host=127.0.0.1 user=minetest password=$psql_minetest_user_password dbname=minetest" >> /home/minetest/.minetest/worlds/world/world.mt
  35. 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
  36. 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
  37. cat mods-list >> /home/minetest/.minetest/worlds/world/world.mt
  38. echo "Copy mods folder"
  39. cp -r mods /home/minetest/.minetest/mods
  40. echo "Fix privileges on /home/minetest"
  41. chown minetest:minetest /home/minetest/ -cR
  42. if [ -z "$1" ]
  43. then
  44. echo "Start minetestsrv service"
  45. systemctl start minetestsrv
  46. fi