#!/bin/sh
for repocop_pkg_key in `ls $REPOCOP_STATEDIR/init-script`; do
    keydir="$REPOCOP_STATEDIR/init-script/$repocop_pkg_key"
    STATUS=ok
    MESSAGE=
    for i in "$keydir"/*; do
        filename=${i##$keydir}
	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=warn
                    MESSAGE="$MESSAGE/etc/rc.d/init.d/$filename: lsb init header missing. "
                else
		    STATUS=warn
                    MESSAGE="$MESSAGE/etc/rc.d/init.d/$filename: strange executable: neither lsb header nor chkconfig header aren't found. "
                fi
            fi
        fi
    done
    repocop-test-$STATUS -k $repocop_pkg_key "$MESSAGE See http://www.altlinux.org/Services_Policy for details."
done
