#!/bin/bash OK=0 NOK=1 findmgroot(){ PRG="$0" while [ -h "$PRG" ]; do ls=`ls -ld "$PRG"` link=`expr "$ls" : '.*-> \(.*\)$'` if expr "$link" : '.*/.*' > /dev/null; then PRG="$link" else PRG=`dirname "$PRG"`/"$link" fi done PRGDIR=`dirname "$PRG"` MGROOT=`cd "$PRGDIR/../.." ; pwd` if [ -z "$MGROOT" ]; then echo "ERR_MGROOT_NOT_DEFINED" return $ERR_MGROOT_NOT_DEFINED else return $OK fi } findmgroot MYGRID_LICENSE_FILE="$MGROOT/resources/CODELICENSE" MYGRID_LICENSE_FILE_LENGTH=`cat $MYGRID_LICENSE_FILE | wc -l` if [ $# -lt 1 ];then # usage exit 0 fi dir=$1 cont=0 contok=0 for i in `find $dir -name "*.java"` do cont=`expr $cont + 1` MYGRID_LICENSE_TMP=$i.tmp.$$ head -n $MYGRID_LICENSE_FILE_LENGTH $i > $MYGRID_LICENSE_TMP diff $MYGRID_LICENSE_FILE $MYGRID_LICENSE_TMP > /dev/null if [ $? -eq 0 ]; then contok=`expr $contok + 1` fi rm -f $MYGRID_LICENSE_TMP done if [ ${cont} -eq ${contok} ]; then echo "-- License OK in $cont/$contok files --" exit $OK else echo "-- Error on licenses --" exit $NOK fi