#!/bin/bash
JOBS_DIR=/var/www/html/its/.jobs
SCRIPTS_DIR=/var/www/html/its/.submit
gen_xrsl () {
cat > strags_agent.xrsl < job.xrsl
# submit job
arcsub -j job.id -z "$SCRIPTS_DIR/arc.client.conf" -S org.ogf.glue.emies.activitycreation -d INFO job.xrsl >submit.log 2>&1
if [ $? -eq 0 ]; then
echo 1 > "./status"
fi
cd -
}
monitor_job () {
local jobdir=$1
cd $jobdir
# get state
jobstate="$( arcstat -j job.id | sed -n '/^\s*State:/s/^\sState:\s*\([a-zA-Z]\+\)/\1/p' )"
# save state if fetched
if [ -n "$jobstate" ]; then
if [ "$jobstate" == "Finished" ]; then
echo 3 > "./status"
arcstat -j job.id | sed -n '/^\s*Exit\sCode:/p' > "./status.info"
else
echo 2 > "./status"
echo $jobstate > "./status.info"
fi
fi
cd -
}
get_results () {
local jobdir=$1
cd $jobdir
# get results
mkdir results
arcget -j job.id -D results
# archive results
tar cjf results.tar.bz2 results
echo 4 > "./status"
}
mail_results () {
local jobdir=$1
cd $jobdir
# source params
source job.params
# e-mail if defined
if [ -n "$EMAIL" ]; then
cat <