#!/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 dropdb minetest_players
sudo -u postgres createdb minetest
sudo -u postgres createdb minetest_players
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;"

echo "Start minetestsrv service"
systemctl start minetestsrv
