This file is indexed.

/usr/share/arc/submit-DGBridge-job is in nordugrid-arc-arex 5.0.5-1ubuntu1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
#!/bin/sh
# set -x
#
#  Based on globus submission script for pbs
#
#  Submits job to the 3GBridge.
#  Input: path to grami file (same as Globus).
#
#opposed to other backends there is no jobscript

echo "----- starting submit_DGBridge_job -----" 1>&2
joboption_lrms=DGBridge

# ARC1 passes the config file first.
if [ "$1" = "--config" ]; then shift; ARC_CONFIG=$1; shift; fi

basedir=`dirname $0`
basedir=`cd $basedir > /dev/null && pwd` || exit $?

pkgdatadir="$basedir"

. ${pkgdatadir}/submit_common.sh || exit $?

##############################################################
# Parse grami file, read arc config
##############################################################
#output the grami file
init $1

#extract staging info:
bdir=$dgbridge_stage_dir
bweb=$dgbridge_stage_prepend

failures_file="$joboption_controldir/job.$joboption_gridid.failed"

if [ -z "${RUNTIME_NODE_SEES_FRONTEND}" ] ; then
  if [ -z "${RUNTIME_LOCAL_SCRATCH_DIR}" ] ; then
    echo "Need to know at which directory to run job: RUNTIME_LOCAL_SCRATCH_DIR must be set if RUNTIME_NODE_SEES_FRONTEND is empty" 1>&2
    echo "Submission: Configuration error.">>"$failures_file"
    exit 1
  fi
fi

##############################################################
# Zero stage of runtime environments
# In the dg bridge this should set the 
# endpoint,grid and app, and VO access 
# $DG_Endpoint, $DG_Grid, $DG_App, $DG_AllowedVOs 
#
# There must be exactly one runtime environment
##############################################################


joboption_num=0
eval "var_is_set=\${joboption_runtime_$joboption_num+yes}"
while [ ! -z "${var_is_set}" ] ; do
  eval "var_value=\${joboption_runtime_$joboption_num}"
  if [ -r "$RUNTIME_CONFIG_DIR/${var_value}" ] ; then
     cmdl="$RUNTIME_CONFIG_DIR/${var_value}"
     sourcewithargs $cmdl 0 1>&2
     if [ $? -ne '0' ] ; then
       echo "ERROR: runtime script ${var_value} failed" 1>&2
       exit 1
     fi
  else
     echo "ERROR: runtime script ${var_value} is missing" 1>&2
     exit 1
  fi
  joboption_num=$(( $joboption_num + 1 ))
  eval "var_is_set=\${joboption_runtime_$joboption_num+yes}"
done

# There must be exactly one runtime environment

if [ "$joboption_num" -eq 0 ]; then
   echo "ERROR: No runtime environment specified." 1>&2
   exit 1
fi
if [ "$joboption_num" -gt 1 ]; then
   echo "ERROR: More than one runtime environment specified." 1>&2
   exit 1
fi


##############################################################
# Start job script
#Note:  there is no script for DGBridge
##############################################################

# choose queue
#if [ ! -z "${joboption_queue}" ] ; then
 # here we must extract and check endpoint data
 # once the RTE per queue options is implemented
#fi

############################################################
# DG:
# check that EP,APP and Grid has been set
###########################################################

if [ -z "$DG_App"  ]; then
   echo "ERROR: RTE has not set the application id." 1>&2
   exit 1
fi
if [ -z "$DG_Endpoint"  ]; then
   echo "ERROR: RTE has not set the endpoint address." 1>&2
   exit 1
fi
if [ -z "$DG_Grid"  ]; then
   echo "ERROR: RTE has not set the target grid." 1>&2
   exit 1
fi
if [ -z "$DG_AllowedVOs"  ]; then
   echo "ERROR: RTE has not set any allowed VOs." 1>&2
   exit 1
fi

############################################################
# DG:
# check that the user has correct VO
###########################################################

# check is performed in the plugin now.

##############################################################
#  DGBridge:
#  calculate md5sums of input files and move input files to
#   be served from apache (perhaps Attic in the future)
##############################################################
#set storage dir from config



#stageweb="http://edgi-dev.nbi.dk:9090/3GBridge/in/$joboption_gridid"
#stagedir="/var/www/3GBridge/in/$joboption_gridid/"
stageweb=$bweb"/in/$joboption_gridid"
stagedir=$bdir"/in/$joboption_gridid/"
#clean dir and link
stageweb=`echo $stageweb|sed -e 's/^[ \t]*//'`
stagedir=`echo $stagedir|sed -e 's/^[ \t]*//'`

DG_Inputlist=""
# read files
inputs0=$joboption_directory/*
#remove directories
inputs=""
for inf in $inputs0; do
 if [ -f $inf ]; then
   inputs="$inputs$inf "
 fi
done

if [ ! -z "$inputs" ]; then

  mkdir $stagedir
  chmod a+rx $stagedir
  for infile in $inputs; do
    
    #calc md5 and size
    mdsum=`md5sum $infile`
    infmdsum=${mdsum%%\ *}
    infsize=`stat -c %s $infile` 
    cp $infile $stagedir
    DG_Inputlist="$DG_Inputlist -i ${infile##*/}=$stageweb/${infile##*/}=$infmdsum=$infsize"    
  done
  chmod a+rx -R $stagedir
fi

#get files from .3GData I.e. atticlinks
dgdatafile=$joboption_controldir/job.$joboption_gridid.3gdata
if [ -f $dgdatafile ]; then
 while read line; do
      if [ ${#line} -gt 2 ]; then
        infile=${line%% *}
        infurl=${line#* }
        infurl=${infurl%;*}
        infmd5=${line#*md5=}
        infmd5=${infmd5%\:*}
        infsize=${line#*size=}
        infsize=${infsize%:*}
        DG_Inputlist="$DG_Inputlist -i $infile=$infurl=$infmd5=$infsize"
      fi
  done < $dgdatafile
fi


############################################################
# DG:
# create input and output list
###########################################################
DG_Outputlist=""
outfile=$joboption_controldir/job.$joboption_gridid.output
outputfs=`cat $outfile`

for ofile in $outputfs; do
 DG_Outputlist="$DG_Outputlist -o ${ofile#/} "
done 

###########################################################
#  Get Arguments from job
###########################################################

DG_Args=""
# remember to set -a flag if there are arguments
i=1
joboption_args=
eval "var_is_set=\${joboption_arg_$i+yes}"
while [ ! -z "${var_is_set}" ] ; do
   eval "var_value=\${joboption_arg_$i}"
   # Use -- to avoid echo eating arguments it understands
   var_value=`echo -- "$var_value" |cut -f2- -d' '| sed 's/\\\\/\\\\\\\\/g' | sed 's/"/\\\"/g'`
   joboption_args="$joboption_args \"${var_value}\""
   i=$(( $i + 1 ))
   eval "var_is_set=\${joboption_arg_$i+yes}"
done
if [ ! -z "$joboption_args" ]; then
   temp_arg=`echo "$joboption_args" | sed 's/^[ \t]*//' | sed 's/^\"//' | sed 's/\"$//'` 
   DG_Args="-a \"$temp_arg\""
fi

###########################################################
#  Get environment variables from job
#  remember to set: PROXY_USERDN="/C=HU/..." for xtremweb
###########################################################
DN=`grep -i "^subject=" $joboption_controldir/job.$joboption_gridid.local | sed "s/subject=//"`
DG_Env="-E PROXY_USERDN=\"$DN\" "

echo "# Setting environment variables as specified by user" 1>&2
has_gridglobalid=''
i=0
eval "var_is_set=\${joboption_env_$i+yes}"
while [ ! -z "${var_is_set}" ] ; do
  eval "var_value=\${joboption_env_$i}"
  if [ "$var_value" ] && [ -z "${var_value##GRID_GLOBAL_JOBID=*}" ]; then
      has_gridglobalid=yes
  else
     var_escaped=`echo "$var_value" | sed "s/'/'\\\\\''/g" | sed "s/\"/\\\\\"/g" | sed "s/^\'//" | sed "s/\'$/\"/" | sed "s/=/=\"/"`
     echo "# var $i: $var_escaped" 1>&2
  
     DG_Env="$DG_Env -E $var_escaped"
  fi
  i=$(( $i + 1 ))
  eval "var_is_set=\${joboption_env_$i+yes}"
done


#######################################
#  Submit the job
#######################################

cmdline="wsclient -e $DG_Endpoint -m add -n $DG_App -g $DG_Grid $DG_Env $DG_Inputlist $DG_Outputlist $DG_Args"
echo "running command: $cmdline" 1>&2

dato=`date +%Y-%m-%d`
edgilog=$joboption_controldir/3gbridge_logs/$dato
dato=`date +%Y-%m-%d_%H:%M:%S`

OUT=$(eval "$cmdline 2>&1")
if [ $? -eq 0 ]; then
   jobid="$DG_Endpoint|$OUT"
   #write EDGI monitor log
   msg="dt=$dato event=job_submission bridge_id=$DG_Endpoint job_id=$joboption_gridid job_id_bridge=\"$jobid\" status=Submitted"
   flock -w 10 $edgilog -c "echo $msg >> $edgilog"
   if [ $? = 1 ]; then
     echo "Failed to log monitor data to: $edgilog" 1>&2
   fi
   # write output to arg file
   echo "joboption_wsendpoint=$DG_Endpoint" >> $arg_file
   echo "joboption_jobid=\"$jobid\"" >> $arg_file
   echo "job submitted successfully!" 1>&2
   echo "local job id: $jobid" 1>&2
   echo "----- exiting submit_DGBridge_job -----" 1>&2
   echo "" 1>&2
   exit 0
fi

#write EDGI monitor log
msg="dt=$dato event=job_submission bridge_id=$DG_Endpoint job_id=$joboption_gridid status=Failed"
echo "monitor: $msg"
flock -w 10 $edgilog -c "echo $msg >> $edgilog"
if [ $? = 1 ]; then
  echo "Failed to log monitor data to: $edgilog" 1>&2
fi

echo "jobsubmission failed." 1>&2
echo "$OUT" 1>&2
echo "----- exiting submit_DGBridge_job -----" 1>&2
echo "" 1>&2
exit 1