From b07b944a787f8fd69314291bca8100564d85fd39 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Tue, 3 Dec 2024 10:26:46 +0100 Subject: [PATCH] update docker init --- docker/init.sh | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/docker/init.sh b/docker/init.sh index 960cc2e5..04fc7256 100755 --- a/docker/init.sh +++ b/docker/init.sh @@ -29,10 +29,14 @@ # 2024-10-30 v1.22 <axel.hahn@unibe.ch> added: Open Mysql client in container # 2024-10-30 v1.23 <axel.hahn@unibe.ch> added: show menu hints why some menu items are visible # 2024-11-20 v1.24 <axel.hahn@unibe.ch> fix menu with started database less app; apply template permissions on target file; add $WEBURL; remove $frontendurl +# 2024-11-20 v1.25 <axel.hahn@unibe.ch> fix menu startup containers +# 2024-11-21 v1.26 <axel.hahn@unibe.ch> Reset colors in _checkConfig # ====================================================================== cd "$( dirname "$0" )" || exit 1 +_version="1.26" + # init used vars gittarget= WEBURL= @@ -42,7 +46,6 @@ _self=$( basename "$0" ) # shellcheck source=/dev/null . "${_self}.cfg" || exit 1 -_version="1.24" # git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git selfgitrepo="docker-php-starterkit.git" @@ -60,6 +63,7 @@ fgReset="\e[0m" # running containers DC_WEB_UP=0 DC_DB_UP=0 +DC_ALL_UP=0 # repo of docker-php-starterkit is here? DC_REPO=1 @@ -84,11 +88,11 @@ function _checkConfig(){ # --- v1.24 if [ -z "$WEBURL" ]; then - echo -e "${fgBrown}INFO: add 'WEBURL=\"/\"' in your ${_self}.cfg. It is a new var since v1.24" + echo -e "${fgBrown}INFO: add 'WEBURL=\"/\"' in your ${_self}.cfg. It is a new var since v1.24${fgReset}" WEBURL="/" fi if [ -n "$frontendurl" ]; then - echo "INFO: Remove frontendurl=$frontendurl in your ${_self}.cfg. It is obsolete since v1.24" + echo -e "${fgBrown}INFO: Remove frontendurl=$frontendurl in your ${_self}.cfg. It is obsolete since v1.24${fgReset}" fi } @@ -119,6 +123,8 @@ function _getStatus_docker(){ DC_WEB_UP=0 DC_DB_UP=0 + DC_ALL_UP=0 + grep -q "${APP_NAME}-server" <<< "$_out" && DC_WEB_UP=1 grep -q "${APP_NAME}-db" <<< "$_out" && DC_DB_UP=1 @@ -128,6 +134,14 @@ function _getStatus_docker(){ return fi + if [ "${DC_WEB_UP}" = "1" ] && [ "${DC_DB_UP}" = "1" ]; then + DC_ALL_UP=1 + fi + + if [ "$DB_ADD" = "false" ] && [ "${DC_WEB_UP}" = "1" ]; then + DC_ALL_UP=1 + fi + } # Get web url of the application @@ -204,9 +218,7 @@ function showMenu(){ echo "${_spacer}$( _key T ) - remove generated files" echo fi - if [ $DC_WEB_UP -eq 0 ] \ - || [ $DC_DB_UP -eq 0 ] && [ ! "$DB_ADD" = "false" ] \ - || [ $_bAll -eq 1 \ + if [ $DC_ALL_UP -eq 0 ] || [ $_bAll -eq 1 \ ]; then if [ $DC_CONFIG_CHANGED -eq 0 ] || [ $_bAll -eq 1 ]; then menuhint $_bAll "A container is down and config is unchanged" -- GitLab