neb/tools/repo/check.d/10-crontabs.sh
2023-10-26 17:11:40 +02:00

24 lines
No EOL
615 B
Bash
Executable file

#!/bin/bash
set -e
for cronfile in skel/etc/cron.d/*; do
basename=$(basename $cronfile)
sum=$(sha1sum $cronfile)
if [ -f .neb/cron/$basename-sum.txt ]; then
[ "$(cat .neb/cron/$basename-sum.txt)" = "$sum" ] && continue
else
mkdir -p .neb/cron
fi
echo "checking $cronfile..."
if ! echo "$cronfile" | grep -q "."; then
echo "$cronfile: crontabs may not have an extension"
exit 1
fi
if ! crontab -T $cronfile &> /dev/null; then
echo "$cronfile: crontab syntax error"
exit 1
fi
echo "$sum" > .neb/cron/$basename-sum.txt
done