From 9af64307b3caa0c91bdfde9205800276032c186c Mon Sep 17 00:00:00 2001 From: qiaofeng1227 <76487013@qq.com> Date: Fri, 26 Aug 2022 14:59:45 +0800 Subject: [PATCH] Update init.sh.jinja2 --- apps/roles/role_init/templates/init.sh.jinja2 | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/roles/role_init/templates/init.sh.jinja2 b/apps/roles/role_init/templates/init.sh.jinja2 index bcd5debc..52a173a2 100644 --- a/apps/roles/role_init/templates/init.sh.jinja2 +++ b/apps/roles/role_init/templates/init.sh.jinja2 @@ -26,10 +26,10 @@ fi # change all the variables to real value,such as DB_MYSQL_PASSWORD=$APP_PASSWORD=>DB_MYSQL_PASSWORD=ues983ks9309023! cd /data/apps/{{app_name}} -export $(cat .env) -envsubst < .env > temp -cat temp > .env -rm -f temp +while [ `grep -c "$" .env` -ne '0' ] +do + replace_with_value_env +done # init APP_URL app_url_replace=$(cat /data/apps/{{app_name}}/.env |grep APP_URL_REPLACE) @@ -64,3 +64,10 @@ echo " " >> /credentials/password.txt {% endfor %} sudo echo "init docker ended at" $(date -d now) 1>> /tmp/init_debug.txt + +replace_with_value_env(){ + export $(cat .env) + envsubst < .env > temp + cat temp > .env + rm -f temp +}