forked from globocom/secDevLabs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[REFACT] Add loading to A5 initialization
- Loading branch information
Showing
1 changed file
with
50 additions
and
14 deletions.
There are no files selected for viewing
64 changes: 50 additions & 14 deletions
64
owasp-top10-2017-apps/a5/ecommerce-api/deployments/check-init.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 |