#!/bin/sh -efu

LOGDIR=/var/log/nagwad

ls -b "$LOGDIR/osec" |
    while read NAME; do
        if [ $? -gt 0 ]; then
            echo "ERROR the checker is broken"
            exit 1
        fi

        CHANGES="$(grep -v '(chg=0,add=0,del=0)' "$LOGDIR/osec/$NAME")"
        if [ -n "$CHANGES" ]; then
            echo "ERROR $CHANGES"
            exit 2
        fi
    done

ret=$?
if [ $ret -eq 0 ]; then
    echo "OK no changes"
fi  

exit $ret
