#!/bin/sh

set -eu

DEPRECATED_DEBIAN_MOD_PATH="/usr/share/games/minetest/mods"

# check old mod path until existing Debian luanti mods (minetest-mod-*) migrate to the new one
if [ -z "${MINETEST_MOD_PATH:-}" ]; then
  export MINETEST_MOD_PATH="${DEPRECATED_DEBIAN_MOD_PATH}"
else
  # append if user defined a mod path
  export MINETEST_MOD_PATH="${MINETEST_MOD_PATH}:${DEPRECATED_DEBIAN_MOD_PATH}"
fi

exec /usr/libexec/luanti/luantiserver \
    --config /etc/luanti/default.conf \
    --logfile /var/log/luanti/default.log \
    "$@"
