#!/bin/bash

PATH=/bin:/usr/bin

jsv_on_start()
{
   jsv_send_env
   return
}

jsv_on_verify()
{

   do_correct="false" 
   do_wait="false"

   l_hard=$(jsv_get_param l_hard)
   if [ "$l_hard" != "" ]; then
      has_h_license=$(jsv_sub_is_param l_hard license)
      if [ "$has_h_license" = "true" ]; then
          amount_h_license=$(jsv_sub_get_param l_hard license)
          if [ "$amount_h_license" -eq 0 ]; then
              jsv_sub_add_param l_hard normal=TRUE
          fi
      fi
   else
       jsv_sub_add_param l_hard normal=TRUE
   fi

   if [ "$do_wait" = "true" ]; then
      jsv_reject_wait "Job is rejected. It might be submitted later."
   elif [ "$do_correct" = "true" ]; then
      jsv_correct "Job was modified before it was accepted"
   else
      jsv_accept "Job is accepted"
   fi
   return
}

. ${SGE_ROOT}/util/resources/jsv/jsv_include.sh

jsv_main
