#!/bin/sh
set -e

case "$1" in
    configure)
        # The nginx app config shipped with this package (apps-available/
        # admin-ui.conf) only takes effect after a reload; without one the
        # box keeps serving with the old headers until the next boot. Only
        # when nginx runs, and only with a passing config test (a broken
        # config must not take the running web server down). In setup mode
        # the admin-ui conf is not enabled yet; the reload is harmless then.
        if command -v nginx >/dev/null 2>&1 && systemctl is-active --quiet nginx; then
            if nginx -t >/dev/null 2>&1; then
                systemctl reload nginx || echo "trutz-frontend: nginx reload failed" >&2
            else
                echo "trutz-frontend: nginx config test failed, not reloading" >&2
            fi
        fi
        ;;
esac

#DEBHELPER#

exit 0
