#! /bin/bash
#------------------------------------------------------------------------------
#$Author: saulius $
#$Date: 2017-12-15 04:34:02 +0000 (Fri, 15 Dec 2017) $
#$Revision: 4004 $
#$URL: file:///home/saulius/svn-repositories/paskaitos/VU/software/assignment-evaluation/trunk/scripts/do-check-BPKM-3rd--executable-files $
#------------------------------------------------------------------------------
#*
# Check that the project has an executable file.
#**

set -ue
## set -x

DIRECTORY="$1"

ID='$Id: do-check-BPKM-3rd--executable-files 4004 2017-12-15 04:34:02Z saulius $'

cd "${DIRECTORY}"

COUNT=$(find . \
             -name .svn -prune -o \
             -name .git -prune -o \
             \( -name getfasta -o -name getpdbx \) -a \
             -print | wc -l)

## echo $0: COUNT=$COUNT >&2

if [ $COUNT -le 0 ]
then
    
    cat <<EOF
-- [AUTO;INTERFACE;$(echo $ID | sed 's/\$//g')]

   Jūsų projekto programa ar skriptas turi vadintis 'getfasta' arba
   'getpdbx', bet toks failas neaptiktas (-5 balai);

EOF

    exit 0
fi

COUNTX=$(find . \
             -name .svn -prune -o \
             -name .git -prune -o \
             \( -name getfasta -o -name getpdbx \) -a \
             -type f -perm /111 \
             -print | wc -l)

## echo $0: COUNT=$COUNT >&2

if [ $COUNTX -le 0 ]
then
    
    cat <<EOF
-- [AUTO;INTERFACE;$(echo $ID | sed 's/\$//g')]

   Jūsų projekto programa 'getfasta' arba 'getpdbx' turi būti vykdoma
   visiems naudotojams, bet Jūsų programai vykdymo bitai nenustatyti
   (-5 balai);

EOF

fi
