From 7bf4bc661aff7252056f36000293fee94bddd969 Mon Sep 17 00:00:00 2001 From: "Arnaud G. GIBERT" Date: Mon, 25 Nov 2024 01:08:25 +0100 Subject: [PATCH] - Add prefix_add function. --- sbin/docker_mk_env | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/sbin/docker_mk_env b/sbin/docker_mk_env index e581d2b..d101af1 100755 --- a/sbin/docker_mk_env +++ b/sbin/docker_mk_env @@ -15,6 +15,24 @@ version="$1" +#------------------------------------------------------------------------------- +function prefix_add +{ + prefix=$1 + separator=$2 + var=$3 + + + if [[ "${prefix}" != "" ]] + then + echo -n "${prefix}${separator}" + fi + + echo "${var}" +} + + + #------------------------------------------------------------------------------- function dynvar_export { @@ -64,10 +82,10 @@ function docker_service_add if [[ "${service_name}" == "${APPL_NAME}" ]] then dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}:${target_version}" - dynvar_export "${varible_prefix}_HOST_NAME" "${HOST_NAME_PREFIX}-webapp" + dynvar_export "${varible_prefix}_HOST_NAME" "$( prefix_add "${HOST_NAME_PREFIX}" "-" "webapp")" else dynvar_export "${varible_prefix}_IMG_URL" "${target_url_prefix}/${target_name}:${target_version}" - dynvar_export "${varible_prefix}_HOST_NAME" "${HOST_NAME_PREFIX}-${service_name}" + dynvar_export "${varible_prefix}_HOST_NAME" "$( prefix_add "${HOST_NAME_PREFIX}" "-" "${service_name}")" fi