From 5269414564abd4b95cf55940bb665cd7576abb0f Mon Sep 17 00:00:00 2001 From: Raine Date: Thu, 26 Oct 2023 17:11:40 +0200 Subject: [PATCH] fix: also for cron --- tools/repo/check.d/10-crontabs.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/repo/check.d/10-crontabs.sh b/tools/repo/check.d/10-crontabs.sh index 23fea1d..7c0e2cc 100755 --- a/tools/repo/check.d/10-crontabs.sh +++ b/tools/repo/check.d/10-crontabs.sh @@ -1,14 +1,24 @@ -#!/bin/sh +#!/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 ! [ $(tail -c1 "$cronfile" | wc -l) -gt 0 ]; then - echo "$cronfile: crontabs must end with a newline" + if ! crontab -T $cronfile &> /dev/null; then + echo "$cronfile: crontab syntax error" exit 1 fi + + echo "$sum" > .neb/cron/$basename-sum.txt done \ No newline at end of file