#!/bin/sh

# ugly and limited hack. make cronie restart itself
if [ -x /bin/awk -a -x /bin/grep -a -f /var/log/cron ]; then
	LC_ALL=C /bin/awk -v d="$(LC_ALL=C date "+%b %e")" ' $1 " " $2 ~ d' /var/log/cron \
		| /bin/grep -qE "PAM.*(Modu. jest nieznany|Module is unknown)" \
		&& echo "crond is failing on PAM, restarting ( https://github.com/cronie-crond/cronie/issues/87 )" >&2 \
		&& /sbin/service crond try-restart
fi
exit 0
