From f47a4499f196f0e9f5b1f719b6cac42556a81f6c Mon Sep 17 00:00:00 2001 From: Bas Zoetekouw Date: Fri, 27 Feb 2026 15:52:26 +0100 Subject: [PATCH] Implement default paths for start-dev-env --- core/start-dev-env.sh | 30 +++++++++++++++++++++++++----- stepup/start-dev-env.sh | 18 ++++++++++++++++-- 2 files changed, 41 insertions(+), 7 deletions(-) diff --git a/core/start-dev-env.sh b/core/start-dev-env.sh index b5ca537..94aea47 100755 --- a/core/start-dev-env.sh +++ b/core/start-dev-env.sh @@ -19,6 +19,15 @@ else echo -e "${GREEN}No .env file was read.${ENDCOLOR}" fi +# Define default paths of the apps +declare -A default_app_paths +default_app_paths["engine"]="../../OpenConext-engineblock" +default_app_paths["profile"]="../../OpenConext-profile" +default_app_paths["sbs"]="../../SBS" +default_app_paths["spdashboard"]="../../sp-dashboard/" +default_app_paths["userlifecycle"]="../../OpenConext-user-lifecycle" + + # Get script directory SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -113,11 +122,16 @@ while [[ $# -gt 0 ]]; do path=$(echo "$arg" | cut -d ':' -f 2) # Basic validation - if [[ -z "$app" ]] || [[ -z "$path" ]]; then + if [[ -z "$app" ]]; then echo -e "${RED}Invalid argument format: '$arg'. Expected :${ENDCOLOR}" exit 1 fi + if [[ -z "$path" || "$path" == "$app" ]]; then + path=${default_app_paths[$app]} + echo "Using default path '$path' for app '$app'" + fi + # Check if the app is a valid subdirectory in the APP_DIR directory if ! [[ $app =~ ^[a-zA-Z0-9_-]+$ ]]; then echo -e "${RED}The specified app '${app}' is not a valid name for an app.${ENDCOLOR}\n"; @@ -129,13 +143,19 @@ while [[ $# -gt 0 ]]; do exit 1; fi - # Replace "~/" with the user's home directory - path=${path/#\~/$HOME} + if [[ -z "$path" || "$path" == "$app" ]]; then + path=${default_app_paths[$app]} + echo "Using default path '$path' for app '$app'" + fi + + # Canonicalize path + orig_path=path + path=$( readlink -f "$path" ) # Test if the specified path(s) exist. - if [ ! -d "${path}" ]; then + if [[ -z "$path" || ! -d "${path}" ]]; then echo -e "${RED}The specified path for app '${app}' is not a directory."; - echo -e "Please verify that the '${path}' directory exists.${ENDCOLOR}\n"; + echo -e "Please verify that the '${orig_path}' directory exists.${ENDCOLOR}\n"; exit 1; fi diff --git a/stepup/start-dev-env.sh b/stepup/start-dev-env.sh index 7688247..dbd3206 100755 --- a/stepup/start-dev-env.sh +++ b/stepup/start-dev-env.sh @@ -33,6 +33,15 @@ else echo -e "${GREEN}No .env file was read.${ENDCOLOR}" fi +# Define default paths of the apps +declare -A default_app_paths +default_app_paths["webauthn"]="../../Stepup-Webauthn" +default_app_paths["middleware"]="../../Stepup-Middleware" +default_app_paths["gateway"]="../../Stepup-Gateway" +default_app_paths["ra"]="../../Stepup-RA" +default_app_paths["tiqr"]="../../Stepup-tiqr" +default_app_paths["azuremfa"]="../../Stepup-Azure-MFA" + # Get script directory SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" @@ -153,8 +162,13 @@ while [[ $# -gt 0 ]]; do exit 1; fi - # Replace "~/" with the user's home directory - path=${path/#\~/$HOME} + if [[ -z "$path" || "$path" == "$app" ]]; then + path=${default_app_paths[$app]} + echo "Using default path '$path' for app '$app'" + fi + + # Canonicalize path + path=$(readlink -f "$path") # Test if the specified path(s) exist. if [ ! -d "${path}" ]; then