diff --git a/owasp-top10-2017-apps/a5/ecommerce-api/deployments/check-init.sh b/owasp-top10-2017-apps/a5/ecommerce-api/deployments/check-init.sh index 6d50b255b..a61f0531e 100755 --- a/owasp-top10-2017-apps/a5/ecommerce-api/deployments/check-init.sh +++ b/owasp-top10-2017-apps/a5/ecommerce-api/deployments/check-init.sh @@ -1,36 +1,72 @@ #!/bin/bash # -# This script prints initialization messages after the compose phase. +# This script verifies if SecDevLabs app has properly start-up. # -COLOR_RESET='\033[0m' +COLOR_RED='\033[31m' COLOR_YELLOW='\033[33m' COLOR_GREEN='\033[32m' COLOR_BLUE='\033[1;34m' +COLOR_RESET='\033[0m' PROJECT='A5 Vulnerable Ecommerce API' PORT=8888 -TRIES=20 +TRIES=480 +LOADING=0 printf "${COLOR_YELLOW}SecDevLabs: 👀 Your app is starting!\n${COLOR_RESET}" -while : ;do + +while : ; do `curl -s -f http://localhost:$PORT > /dev/null` - if [ $? == 0 ]; then + if [ $? == 0 ] ; then break fi - if [ $TRIES == 20 ]; then - printf "${COLOR_GREEN}SecDevLabs: ☕️ Hmmm... Sounds good!${COLOR_RESET}\n" - fi - if [ $TRIES == 0 ]; then + if [ $TRIES == 0 ] ; then break fi - sleep 5 - TRIES=$TRIES-1 - printf "${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting...\n${COLOR_RESET}" + TRIES=$((TRIES-1)) + sleep 0.25 + + # Loading animation + if [ $LOADING == 14 ]; then + LOADING=0 + fi + if [ $LOADING == 0 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (*-------) ${COLOR_RESET}" + elif [ $LOADING == 1 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (-*------) ${COLOR_RESET}" + elif [ $LOADING == 2 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (--*-----) ${COLOR_RESET}" + elif [ $LOADING == 3 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (---*----) ${COLOR_RESET}" + elif [ $LOADING == 4 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (----*---) ${COLOR_RESET}" + elif [ $LOADING == 5 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (-----*--) ${COLOR_RESET}" + elif [ $LOADING == 6 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (------*-) ${COLOR_RESET}" + elif [ $LOADING == 7 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (-------*) ${COLOR_RESET}" + elif [ $LOADING == 8 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (------*-) ${COLOR_RESET}" + elif [ $LOADING == 9 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (-----*--) ${COLOR_RESET}" + elif [ $LOADING == 10 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (----*---) ${COLOR_RESET}" + elif [ $LOADING == 11 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (---*----) ${COLOR_RESET}" + elif [ $LOADING == 12 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (--*-----) ${COLOR_RESET}" + elif [ $LOADING == 13 ]; then + printf "\r${COLOR_YELLOW}SecDevLabs: 👀 Your app is still starting... (-*------) ${COLOR_RESET}" + fi + LOADING=$((LOADING+1)) + # End of loading animation + done if [ $TRIES == 0 ]; then - printf "${COLOR_BLUE}SecDevLabs: Ooops! Something went wrong, please check api details for more information!" + printf "\n${COLOR_RED}SecDevLabs: Ooops! Something went wrong, please check api details for more information!\n${COLOR_RESET}" else - printf "${COLOR_GREEN}SecDevLabs: 🔥 ${PROJECT} is now running at ${COLOR_RESET}${COLOR_BLUE}http://localhost:$PORT${COLOR_RESET}\n" + printf "\n${COLOR_GREEN}SecDevLabs: 🔥 ${PROJECT} is now running at ${COLOR_RESET}${COLOR_BLUE}http://localhost:$PORT${COLOR_RESET}\n" fi \ No newline at end of file