From 64ec44ce3d61bf2165637b8499d61ffe23919d4d Mon Sep 17 00:00:00 2001 From: Michael <m.langguth@fz-juelich.de> Date: Tue, 29 Sep 2020 11:21:46 +0200 Subject: [PATCH] Ensure that 'create_env.sh' and 'generate_workflow_runscripts.sh' can only be executed from the env_setup-directory. --- video_prediction_savp/env_setup/create_env.sh | 2 +- .../env_setup/generate_workflow_runscripts.sh | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/video_prediction_savp/env_setup/create_env.sh b/video_prediction_savp/env_setup/create_env.sh index 4897bf49..8aa6c0a6 100755 --- a/video_prediction_savp/env_setup/create_env.sh +++ b/video_prediction_savp/env_setup/create_env.sh @@ -46,7 +46,7 @@ ENV_DIR=${WORKING_DIR}/${ENV_NAME} # * check if virtual env has already been set up if [[ "${EXE_DIR}" != "env_setup" ]]; then - echo "ERROR: The setup-script for the virtual environment from the env_setup-directory!" + echo "ERROR: Execute 'create_env.sh' from the env_setup-subdirectory only!" return fi diff --git a/video_prediction_savp/env_setup/generate_workflow_runscripts.sh b/video_prediction_savp/env_setup/generate_workflow_runscripts.sh index 4d00e940..c8cc4947 100755 --- a/video_prediction_savp/env_setup/generate_workflow_runscripts.sh +++ b/video_prediction_savp/env_setup/generate_workflow_runscripts.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # # __authors__ = Michael Langguth -# __date__ = '2020_09_24' +# __date__ = '2020_09_29' # # **************** Description **************** # Converts a given template workflow script (path/name has to be passed as first argument) to @@ -52,8 +52,14 @@ add_exp_dir() { HOST_NAME=`hostname` BASE_DIR=`pwd` WORKING_DIR="$(dirname "$BASE_DIR")" +EXE_DIR="$(basename "$BASE_DIR")" ### Some sanity checks ### +# ensure that the script is executed from the env_setup-subdirectory +if [[ "${EXE_DIR}" != "env_setup" ]]; then + echo "ERROR: Execute 'generate_workflow_scripts.sh' from the env_setup-subdirectory only!" + exit 1 +fi # check input arguments if [[ "$#" -lt 2 ]]; then echo "ERROR: Pass path to workflow runscript (without '_template.sh') and pass name of virtual environment..." -- GitLab