#!/bin/sh
files_exist()
{
    [ -e "$1" ]
}
files_exist $REPOCOP_PKG_ROOT/etc/rc.d/init.d/* ] || exec repocop-test-skip
STATUS=ok
MESSAGE=
for i in $REPOCOP_PKG_ROOT/etc/rc.d/init.d/*; do
    filename=${i##$REPOCOP_PKG_ROOT}
    if [ -x $i ]; then
        HAS_INIT=`grep '# chkconfig:' $i`
        HAS_LSB_INIT=`grep '### BEGIN INIT INFO' $i`
        if [ -z "$HAS_LSB_INIT" ]; then
            if [ -n "$HAS_INIT" ]; then
                STATUS=info
                MESSAGE="$MESSAGE$filename: lsb init header missing. "
            else
                STATUS=warn
                MESSAGE="$MESSAGE$filename: strange executable: neither lsb header nor chkconfig header aren't found. "
            fi
        fi
    fi
done
repocop-test-$STATUS $MESSAGE
