#!/bin/sh

set -eu

EXEC_USER=_userausfall

. /etc/default/userausfall

export PYTHONPATH
export DJANGO_SETTINGS_MODULE
export USERAUSFALL_DATA_DIR

if [ "$(id -nu)" = "$EXEC_USER" ]; then
    exec python3 -m django "$@"
elif [ "$(id -u)" = 0 ]; then
    exec su -s "$0" "$EXEC_USER" -- "$@"
else
    echo "please run $(basename "$0") as root or '$EXEC_USER'" >&2
    exit 1
fi