Minetest server startup/shutdown scripts

The following are helper scripts to start and stop a Minetest server on Bash/GNU/Linux. They're totally hacky and sub-optimal, but they do their simple jobs.

start_minetest.sh

#!/bin/bash

MINETEST_HOME=~/minetest

pgrep minetestserver >/dev/null && { echo "Stopping existing instance..."; killall -HUP minetestserver; sleep 2; }

echo "Showing the current configuration"
~/config_summary.sh

echo "Starting minetest server"
${MINETEST_HOME}/bin/minetestserver&

MT_PID="$!"
echo "Started server, PID ${MT_PID}"

stop_minetest.sh

#!/bin/bash

MINETEST_HOME=~/minetest

pgrep minetestserver >/dev/null && { killall -HUP minetestserver; sleep 2; }

echo -e "\nMinetest server has been stopped"

restart_minetest.sh

#!/bin/bash

MINETEST_HOME=~/minetest

pgrep minetestserver >/dev/null && { killall -HUP minetestserver; sleep 2; }

echo "Configuration of minetest.conf"
egrep -v '^#|^


 ${MINETEST_HOME}/minetest.conf

cat ${MINETEST_HOME}/worlds/world/world.mt

echo "Starting minetest server"
${MINETEST_HOME}/bin/minetestserver&

MT_PID="$!"
echo "Started server, PID ${MT_PID}"

config_summary.sh

It's handy to get a visual on the configuration when starting a server.

#!/bin/bash

MINETEST_HOME=~/minetest

echo -e "\nConfiguration of ${MINETEST_HOME}/minetest.conf"
echo -e "============\n"
egrep -v '^#|^


 ${MINETEST_HOME}/minetest.conf

WORLD_CONFIG="${MINETEST_HOME}/worlds/world/world.mt"
echo -e "\nConfiguration of ${WORLD_CONFIG}"
echo -e "============\n"

cat ${WORLD_CONFIG}

backup_worlds.sh

Handy to take a snapshot of things before making significant changes (update

mods, etc).

It would be better to cd into ~/minetest and backup relative paths (an

excercise for the reader!).

!/bin/bash

echo "Backing up all worlds to ~/worlds_all.tgz and ~/mods_global.tgz"

~/stop_minetest.sh

tar cvzf ~/worlds_all.tgz ~/minetest/worlds

tar cvzf ~/mods_global.tgz ~/minetest/mods

~/start_minetest.sh

Messing with Entities

From console mode (F10), invoke Lua directly. Get the object id (n) from the server's log when right clicking, for example.

The ObjectRef is a reference to a ServerActiveObject. Methods can be invoked on it as follows:

minetest.object_refs[n]:set_pos({x=100, y=10, z=100})