neb/tools/repo/check.d/10-crontabs.sh

24 lines
615 B
Bash
Raw Normal View History

2023-10-26 17:11:40 +02:00
#!/bin/bash
2023-10-22 17:45:03 +02:00
set -e
for cronfile in skel/etc/cron.d/*; do
2023-10-26 17:11:40 +02:00
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
2023-10-22 17:45:03 +02:00
echo "checking $cronfile..."
if ! echo "$cronfile" | grep -q "."; then
echo "$cronfile: crontabs may not have an extension"
exit 1
fi
2023-10-26 17:11:40 +02:00
if ! crontab -T $cronfile &> /dev/null; then
echo "$cronfile: crontab syntax error"
2023-10-22 17:45:03 +02:00
exit 1
fi
2023-10-26 17:11:40 +02:00
echo "$sum" > .neb/cron/$basename-sum.txt
2023-10-22 17:45:03 +02:00
done