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

Initial release of bash shell script to convert template workflow scripts to executable ones.

parent f418c60b
No related branches found
No related tags found
No related merge requests found
#!/usr/bin/env bash
# **************** Description ****************
# Converts given template workflow script (path has to be passed as first argument) to
# an executable workflow (Batch) script.
# Note, that this first argument has to be passed with "_template.sh" omitted!
# A second argument can be passed to set the e-mail address.
# On HDF-ML and Juwels, where jutil is available, this is done automatically,
# i.e. no second argument is required.
# Example:
# ./generate_workflow_scripts.sh ../HPC_scripts/generate m.mustermann@fz-juelich.de
# **************** Description ****************
#
#sanity checks
if ! [ $# -eq 1]; then
echo "ERROR: Pass path to workflow script to be generated..."
else
curr_script = $1
fi
if ! [[ -f ${curr_script}_template.sh ]]; then
echo "WARNING: Could not find expected Batch script '${curr_script}_template.sh'."
echo "Thus, no corresponding executable script is created!"
exit 0 # still ok, i.e. only a WARNING is raised
fi
# create copy of template which is modified subsequenty
cp ${curr_script}_template.sh ${curr_script}_op.sh
# remove template identifiers
num_lines=`awk '/Template identifiers/{ print NR }'
line_s=`echo ${num_lines} | cut -d' ' -f 1`
line_e=`echo ${num_lines} | cut -d' ' -f 2`
if [[ ${line_s} == "" || ${line_e} == "" ]]; then
echo "ERROR: ${curr_script}_template.sh exists, but does not seem to be a valid template script."
exit 1
else
sed -e '${line_s},${line_e}d' ${curr_script}_op.sh
fi
# set correct e-mail address if possible, otherwise remove
if ! [ -z "$2" ]; then
USER_EMAIL=$2
else
if [ command -v jutil ]; then
USER_EMAIL=$(jutil user show -o json | grep email | cut -f2 -d':' | cut -f1 -d',' | cut -f2 -d'"')
else
USER_MAIL=""
fi
fi
sed -i "s/--mail-user=.*/--mail-user=$USER_EMAIL/g" ${curr_script}_op.sh
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment