2024-10-05 12:21:38 +02:00
|
|
|
#!/bin/bash
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
set -o errexit
|
|
|
|
|
|
|
|
APPL_HOME_DIR="$(dirname "$(dirname "$0")")"
|
2024-11-03 17:16:33 +01:00
|
|
|
DYNVAR_LIST=""
|
2024-10-05 12:21:38 +02:00
|
|
|
|
|
|
|
version="$1"
|
|
|
|
|
|
|
|
|
|
|
|
|
2024-11-03 17:16:33 +01:00
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
function dynvar_export
|
|
|
|
{
|
|
|
|
var=$1
|
|
|
|
value=$2
|
|
|
|
|
|
|
|
|
|
|
|
eval export ${var}=\"${value}\"
|
|
|
|
|
|
|
|
DYNVAR_LIST+=" ${var}"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
function docker_service_add
|
|
|
|
{
|
|
|
|
varible_prefix="$1"
|
|
|
|
shift
|
|
|
|
|
|
|
|
for var in NAME NAME_FULL URL_PREFIX IMG_NAME VERSION_EXT VERSION_INT PORT_MAIN_EXT PORT_MAIN_INT PORT_ADMIN_EXT PORT_ADMIN_INT USER_NAME GROUP_NAME
|
|
|
|
do
|
|
|
|
dynvar_export "${varible_prefix}_${var}" "$1"
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
|
|
|
|
if [[ $( eval echo \${${varible_prefix}_IMG_NAME}) != "-" ]]
|
|
|
|
then
|
|
|
|
# No Build
|
|
|
|
|
|
|
|
dynvar_export "${varible_prefix}_IMG_URL" "\${${varible_prefix}_URL_PREFIX}/\${${varible_prefix}_IMG_NAME}:\${${varible_prefix}_VERSION_INT}"
|
|
|
|
else
|
|
|
|
# Build
|
|
|
|
|
|
|
|
dynvar_export "${varible_prefix}_IMG_URL" "\${${varible_prefix}_URL_PREFIX}/\${${varible_prefix}_NAME}:\${${varible_prefix}_VERSION_INT}"
|
|
|
|
|
|
|
|
dynvar_export "${varible_prefix}_MODULE_NAME" "\${${varible_prefix}_NAME}"
|
|
|
|
dynvar_export "${varible_prefix}_MODULE_PATH" "src/\${${varible_prefix}_NAME}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
dynvar_export "${varible_prefix}_CONTAINER_NAME" "${CONTAINER_NAME_PREFIX}-\${${varible_prefix}_NAME}"
|
|
|
|
dynvar_export "${varible_prefix}_HOST" "\${${varible_prefix}_CONTAINER_NAME}"
|
|
|
|
|
|
|
|
dynvar_export "${varible_prefix}_PORT_MAIN_EXT" "\$(( \${${varible_prefix}_PORT_MAIN_EXT} + ${PORT_ENV_OFFSET}))"
|
|
|
|
dynvar_export "${varible_prefix}_PORT_SV_EXT" "\$(( \${${varible_prefix}_PORT_MAIN_EXT} + ${PORT_SV_OFFSET}))"
|
|
|
|
dynvar_export "${varible_prefix}_PORT_SV_INT" "9001"
|
|
|
|
|
|
|
|
if [[ $( eval echo \${${varible_prefix}_PORT_ADMIN_EXT}) != "-" ]]
|
|
|
|
then
|
|
|
|
dynvar_export "${varible_prefix}_PORT_ADMIN_EXT" "\$(( \${${varible_prefix}_PORT_ADMIN_EXT} + ${PORT_ENV_OFFSET}))"
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $( eval echo \${${varible_prefix}_USER_NAME}) == "-" ]]
|
|
|
|
then
|
|
|
|
dynvar_export "${varible_prefix}_USER_ID" "-"
|
|
|
|
else
|
|
|
|
if [[ $( eval echo \${${varible_prefix}_USER_NAME}) =~ ^[0-9]+$ ]]
|
|
|
|
then
|
|
|
|
dynvar_export "${varible_prefix}_USER_ID" "\${${varible_prefix}_USER_NAME}"
|
|
|
|
else
|
|
|
|
dynvar_export "${varible_prefix}_USER_ID" "\$( id -u \${${varible_prefix}_USER_NAME})"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ $( eval echo \${${varible_prefix}_GROUP_NAME}) == "-" ]]
|
|
|
|
then
|
|
|
|
dynvar_export "${varible_prefix}_GROUP_ID" "-"
|
|
|
|
else
|
|
|
|
if [[ $( eval echo \${${varible_prefix}_GROUP_NAME}) =~ ^[0-9]+$ ]]
|
|
|
|
then
|
|
|
|
dynvar_export "${varible_prefix}_GROUP_ID" "\${${varible_prefix}_GROUP_NAME}"
|
|
|
|
else
|
|
|
|
dynvar_export "${varible_prefix}_GROUP_ID" "\$( getent group \${${varible_prefix}_GROUP_NAME} | cut -d: -f3)"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
dynvar_export "${varible_prefix}_CONTEXT_PATH" "/${APPL_NAME}/\${${varible_prefix}_NAME}/"
|
|
|
|
|
|
|
|
|
|
|
|
# dynvar_export "${varible_prefix}_" "${varible_prefix}_${}"
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
2024-10-05 12:21:38 +02:00
|
|
|
|
|
|
|
. ${APPL_HOME_DIR}/env
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
if [[ "${version}" != "" ]]
|
|
|
|
then
|
|
|
|
APPL_VERSION="$1"
|
|
|
|
fi
|
|
|
|
|
|
|
|
#-------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
>${APPL_HOME_DIR}/.env
|
|
|
|
|
2024-11-03 17:16:33 +01:00
|
|
|
for var in $( ( grep "^ *[a-zA-Z0-9_-]*=" ${APPL_HOME_DIR}/env | sed -e "s/=.*//" -e "s/ *//"; echo ${DYNVAR_LIST} | sed -e 's/ /\n/g') | sort -u)
|
2024-10-05 12:21:38 +02:00
|
|
|
do
|
|
|
|
echo "${var}='${!var}'" >>${APPL_HOME_DIR}/.env
|
|
|
|
done
|