Skip to content
Snippets Groups Projects
Commit 36a87e9a authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update menu output

parent 7fd07754
No related branches found
No related tags found
1 merge request!15update menu output
This commit is part of merge request !15. Comments created here will be created in the context of that merge request.
...@@ -19,6 +19,7 @@ ...@@ -19,6 +19,7 @@
# 2024-07-19 v1.12 <axel.hahn@unibe.ch> apply shell fixes # 2024-07-19 v1.12 <axel.hahn@unibe.ch> apply shell fixes
# 2024-07-22 v1.13 <axel.hahn@unibe.ch> show info if there is no database container; speedup replacements # 2024-07-22 v1.13 <axel.hahn@unibe.ch> show info if there is no database container; speedup replacements
# 2024-07-22 v1.14 <axel.hahn@unibe.ch> show colored boxes with container status # 2024-07-22 v1.14 <axel.hahn@unibe.ch> show colored boxes with container status
# 2024-07-24 v1.15 <axel.hahn@unibe.ch> update menu output
# ====================================================================== # ======================================================================
cd "$( dirname "$0" )" || exit 1 cd "$( dirname "$0" )" || exit 1
...@@ -32,10 +33,18 @@ _self=$( basename "$0" ) ...@@ -32,10 +33,18 @@ _self=$( basename "$0" )
# shellcheck source=/dev/null # shellcheck source=/dev/null
. "${_self}.cfg" || exit 1 . "${_self}.cfg" || exit 1
_version="1.15"
# git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git # git@git-repo.iml.unibe.ch:iml-open-source/docker-php-starterkit.git
selfgitrepo="docker-php-starterkit.git" selfgitrepo="docker-php-starterkit.git"
_version="1.14" fgGray="\e[1;30m"
fgRed="\e[31m"
fgGreen="\e[32m"
fgBrown="\e[33m"
fgBlue="\e[34m"
fgReset="\e[0m"
# ---------------------------------------------------------------------- # ----------------------------------------------------------------------
# FUNCTIONS # FUNCTIONS
...@@ -44,13 +53,13 @@ _version="1.14" ...@@ -44,13 +53,13 @@ _version="1.14"
# draw a headline 2 # draw a headline 2
function h2(){ function h2(){
echo echo
echo -e "\e[33m>>>>> $*\e[0m" echo -e "$fgBrown>>>>> $*$fgReset"
} }
# draw a headline 3 # draw a headline 3
function h3(){ function h3(){
echo echo
echo -e "\e[34m----- $*\e[0m" echo -e "$fgBlue----- $*$fgReset"
} }
# show help for param -h # show help for param -h
...@@ -274,51 +283,60 @@ function _showContainers(){ ...@@ -274,51 +283,60 @@ function _showContainers(){
local bLong=$1 local bLong=$1
local _out local _out
_out=$( if [ -z "$bLong" ]; then local sUp=".. UP"
docker-compose -p "$APP_NAME" ps local sDown=".. down"
else
# docker ps | grep "$APP_NAME"
docker-compose -p "$APP_NAME" ps
fi)
local Status= local Status=
local StatusWeb="$sDown"
local StatusDb=""
local colWeb= local colWeb=
local colDb= local colDb=
local fgGray="\e[1;30m"
local fgRed="\e[31m"
local fgGreen="\e[32m"
colDb="$fgRed" colDb="$fgRed"
colWeb="$fgRed" colWeb="$fgRed"
_out=$( if [ -z "$bLong" ]; then
docker-compose -p "$APP_NAME" ps
else
# docker ps | grep "$APP_NAME"
docker-compose -p "$APP_NAME" ps
fi)
h2 CONTAINERS h2 CONTAINERS
if [ "$( wc -l <<< "$_out" )" -eq 1 ]; then if [ "$( wc -l <<< "$_out" )" -eq 1 ]; then
if [ "$DB_ADD" = "false" ]; then if [ "$DB_ADD" = "false" ]; then
colDb="$fgGray" colDb="$fgGray"
Status="The web container is <$APP_NAME> is not running. This app has no database container." Status="The web container is not running. This app has no database container."
else else
StatusDb="down"
Status="No container is running for <$APP_NAME>." Status="No container is running for <$APP_NAME>."
fi fi
STATUS_CONTAINERS_UP=1
else else
grep -q "${APP_NAME}-server" <<< "$_out" && colWeb="$fgGreen" grep -q "${APP_NAME}-server" <<< "$_out" && colWeb="$fgGreen"
grep -q "${APP_NAME}-server" <<< "$_out" && StatusWeb="$sUp"
grep -q "${APP_NAME}-db" <<< "$_out" && colDb="$fgGreen" grep -q "${APP_NAME}-db" <<< "$_out" && colDb="$fgGreen"
StatusDb="$sDown"
grep -q "${APP_NAME}-db" <<< "$_out" && StatusDb="$sUp"
if [ "$DB_ADD" = "false" ]; then if [ "$DB_ADD" = "false" ]; then
colDb="$fgGray" colDb="$fgGray"
Status="INFO: This app has no database container." Status="INFO: This app has no database container."
fi fi
fi fi
printf "$colWeb ________________________ $colDb ________________________ \e[0m \n" printf "$colWeb __________________________ $colDb __________________________ $fgReset \n"
printf "$colWeb | %-20s | $colDb | %-20s | \e[0m \n" "" "" printf "$colWeb | %-22s | $colDb | %-22s | $fgReset \n" "" ""
printf "$colWeb | %-20s | $colDb | %-20s | \e[0m \n" "Webserver" "Database" printf "$colWeb | %-22s | $colDb | %-22s | $fgReset \n" "${APP_NAME}-web ${StatusWeb}" "${APP_NAME}-db ${StatusDb}"
printf "$colWeb | %-20s | $colDb | %-20s | \e[0m \n" "${APP_NAME}-web" "${APP_NAME}-db" printf "$colWeb | %-22s | $colDb | %-22s | $fgReset \n" " PHP ${APP_PHP_VERSION}" " ${MYSQL_IMAGE}"
printf "$colWeb | %-20s | $colDb | %-20s | \e[0m \n" "PHP ${APP_PHP_VERSION}" "${MYSQL_IMAGE}" printf "$colWeb | %-22s | $colDb | %-22s | $fgReset \n" " :${APP_PORT}" " :${DB_PORT}"
printf "$colWeb | %-20s | $colDb | %-20s | \e[0m \n" ":${APP_PORT}" ":${DB_PORT}" printf "$colWeb |__________________________| $colDb |__________________________| $fgReset \n"
printf "$colWeb |________________________| $colDb |________________________| \e[0m \n"
if [ -n "$Status" ]; then
echo echo
echo "$Status" echo "$Status"
fi
echo echo
if [ -n "$bLong" ]; then if [ -n "$bLong" ]; then
...@@ -402,12 +420,13 @@ while true; do ...@@ -402,12 +420,13 @@ while true; do
if [ -z "$action" ]; then if [ -z "$action" ]; then
echo "_______________________________________________________________________________"
echo
echo
echo " ${APP_NAME^^} :: Initializer for docker"
echo " ______"
echo "________________________________________________________________________/ $_version"
echo echo
echo "+------------------------------------------------------------------"
echo "|"
echo "| Initializer for docker v$_version << $APP_NAME >>"
echo "|"
echo ":"
_showContainers _showContainers
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment