Skip to content
Snippets Groups Projects
Commit 942a7f63 authored by Michael Langguth's avatar Michael Langguth
Browse files

Several bugfixes in generate_workflow_runscripts.sh

parent 489ec562
No related branches found
No related tags found
No related merge requests found
Pipeline #45263 failed
...@@ -16,25 +16,32 @@ HOST_NAME=`hostname` ...@@ -16,25 +16,32 @@ HOST_NAME=`hostname`
### some sanity checks ### ### some sanity checks ###
# check input arguments # check input arguments
if ! [ $# -lt 1]; then if [[ "$#" -lt 1 ]]; then
echo "ERROR: Pass path to workflow script to be generated..." echo "ERROR: Pass path to workflow runscript (without '_template.sh') to be generated..."
exit 1
else else
curr_script=$1 curr_script=$1
if [ $# -gt 1]; then if [[ "$#" -gt 1 ]]; then
exp_id=$2 exp_id=$2
else else
exp_id="exp1" exp_id="exp1"
fi fi
fi fi
# check existence of template script # check existence of template script
if ! [[ -f ${curr_script}_template.sh ]]; then if ! [[ -f ${curr_script}_template.sh ]]; then
echo "WARNING: Could not find expected Batch script '${curr_script}_template.sh'." echo "WARNING: Could not find expected Batch script '${curr_script}_template.sh'."
echo "Thus, no corresponding executable script is created!" echo "Thus, no corresponding executable script is created!"
if [[ ${curr_script} == *"template"* || ${curr_script} == *".sh"* ]]; then
echo "ERROR: Omit '_template' and/or '.sh' from Bash script argument."
exit 1
else
exit 0 # still ok, i.e. only a WARNING is raised exit 0 # still ok, i.e. only a WARNING is raised
fi fi
fi
# check if target script is unique # check if target script is unique
target_script=${curr_script}_${exp_id}.sh target_script=${curr_script}_${exp_id}.sh
if [[ ]]; then if [[ -f ${target_script} ]]; then
echo "ERROR: ${target_script} already exist." echo "ERROR: ${target_script} already exist."
echo "Set explicitly a different experiment identifier." echo "Set explicitly a different experiment identifier."
exit 1 exit 1
...@@ -43,21 +50,21 @@ fi ...@@ -43,21 +50,21 @@ fi
# create copy of template which is modified subsequently # create copy of template which is modified subsequently
cp ${curr_script}_template.sh ${target_script} cp ${curr_script}_template.sh ${target_script}
# remove template identifiers # remove template identifiers
num_lines=`awk '/Template identifiers/{ print NR }' ${target_script}` num_lines=`awk '/Template identifier/{ print NR }' ${target_script}`
line_s=`echo ${num_lines} | cut -d' ' -f 1` line_s=`echo ${num_lines} | cut -d' ' -f 1`
line_e=`echo ${num_lines} | cut -d' ' -f 2` line_e=`echo ${num_lines} | cut -d' ' -f 2`
if [[ ${line_s} == "" || ${line_e} == "" ]]; then if [[ ${line_s} == "" || ${line_e} == "" ]]; then
echo "ERROR: ${curr_script}_template.sh exists, but does not seem to be a valid template script." echo "ERROR: ${curr_script}_template.sh exists, but does not seem to be a valid template script."
rm ${target_script} # remove copy again
exit 1 exit 1
else else
sed -e '${line_s},${line_e}d' ${target_script} sed -i "${line_s},${line_e}d" ${target_script}
fi fi
# set exp_id in (Batch) script if present # set exp_id in (Batch) script if present
if [[ `grep "exp_id=" ${target_script}` ]]; then if [[ `grep "exp_id=" ${target_script}` ]]; then
sed -i "s/exp_id=.*/exp_id=$exp_id/g" ${target_script} sed -i "s/exp_id=.*/exp_id=$exp_id/g" ${target_script}
fi fi
grep -Fxq "$FILENAME" my_list.txt
# set correct e-mail address in Batch scripts on Juwels and HDF-ML # set correct e-mail address in Batch scripts on Juwels and HDF-ML
if [[ "${HOST_NAME}" == hdfml* || "${HOST_NAME}" == juwels* ]]; then if [[ "${HOST_NAME}" == hdfml* || "${HOST_NAME}" == juwels* ]]; then
if [ command -v jutil ]; then if [ command -v jutil ]; then
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment