#!/bin/sh

RESTART=0
if test x$(systemctl show -p ActiveState --value "nftables.service") != xactive
then
    sleep 2
    systemctl restart nftables.service
    RESTART=1
    sleep 10
fi

if test x$(systemctl show -p ActiveState --value "nftables.service") != xactive
then
    systemctl status nftables.service | mail -s "$(hostname): WARNUNG: nftables nach Boot nicht gestartet, auch nach zweitem Versuch nicht." alarm@hostsharing.net

elif test ${RESTART} -eq 1
then
    systemctl status nftables.service | mail -s "$(hostname): HINWEIS: nftables nach Boot nicht gestartet, zweiter Versuch aber erfolgreich." hostmaster@hostsharing.net
fi
