Test d’une méthode d’agrégation des variables d’environnement.

This commit is contained in:
Benjamin Bohard 2024-09-18 15:33:58 +02:00
parent be14957a0e
commit 49c06fec1a
3 changed files with 35 additions and 9 deletions

10
env/.env vendored
View File

@ -50,11 +50,11 @@ FAKE_SMTP_LOCAL=1
FAKE_SMTP_ACTIVATE=1
# si actif, il faut sans doute lutiliser
# comme passerelle pour le service MTA
#if [ "$FAKE_SMTP_ACTIVATE" -eq 1 ]
#then
# MTA_RELAY_HOST="$FAKE_SMTP_NAME"
# MTA_RELAY_PORT=2525
#fi
if [ "$FAKE_SMTP_ACTIVATE" -eq 1 ]
then
MTA_RELAY_HOST="$FAKE_SMTP_NAME"
MTA_RELAY_PORT=2525
fi
# MARIADB
MARIADB_SERVICE_NAME=mariadb

25
misc/tools/mergeenv.sh Executable file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env -S -i bash
env_files="env/.env env/.env.local"
merged_env="env/.env.merge"
if [ -n "$1" ]
then
env_files="$env_files $1/env/.env $1/env/.env.local"
merged_env="$1/env/.env.merge"
fi
unset PWD
unset SHLVL
for env_file in $env_files
do
set -a
if [ -f "$env_file" ]
then
. $env_file
fi
set +a
done
unset username
export -p | cut -d" " -f3- | sed "/OLDPWD/d" | head -n -1 | sort > "$merged_env"
exit 0

View File

@ -113,7 +113,8 @@ destroyall(){
env(){
for dir in $(ls -d "services"/[0-9][0-9]-* | sort); do
mergeenv $dir/env/.env.merge env/.env.merge $dir/env/.env $dir/env/.env.local
#mergeenv $dir/env/.env.merge env/.env.merge $dir/env/.env $dir/env/.env.local
misc/tools/mergeenv.sh $dir
done
}
@ -208,9 +209,9 @@ services() {
#===========================================================================================================================================
# Include variable d'environnement global
mergeenv env/.env.merge env/.env env/.env.local
#mergeenv env/.env.merge env/.env env/.env.local
misc/tools/mergeenv.sh
. env/.env.merge
# Include service
declare -A services
for dir in $(ls -d "services"/[0-9][0-9]-* | sort); do
@ -338,4 +339,4 @@ else
EchoRouge "nine.sh regen monservice > lance destroy monservice puis up monservice"
fi
echo
echo
echo