#!/usr/bin/sh
# RPM %posttrans: use the administrator's active file-context mappings, including
# semanage overrides. No policy modules, booleans, port changes or chmod/chown.
set -eu
PATH=/usr/sbin:/usr/bin:/sbin:/bin
export PATH

if selinuxenabled; then
    if ! restorecon -R /opt/mail2blog /etc/mail2blog /usr/lib/systemd/system/mailblog.service; then
        echo 'mailblog: SELinux-Dateikontexte konnten nicht wiederhergestellt werden; restorecon und AVC-Protokoll prüfen.' >&2
        exit 1
    fi
else
    status=$?
    # libselinux: 1 means disabled (normal for the build container), not failure.
    if [ "$status" -ne 1 ]; then
        echo 'mailblog: SELinux-Status konnte nicht ermittelt werden.' >&2
        exit "$status"
    fi
fi
