#!/bin/bash ############################################################ # Decription: Script to manage stack docker # # Author: Gilles Mouchet (gilles.mouchet@gmail.com) # Creation Date: 12-06-2025 # Version: 1.0 # Install: If applicable - Install instruction or # see README.md # Usage: If applicable - usage or see README.md # Changelog: # V1.0 - dd-Mmm-2025 - GMo # Added # - Creation of script from scratch # ############################################################ #----------------------------------------------------------------- # Doesn't change anything from here #----------------------------------------------------------------- version="v1.0-rc1" progName="./$(/bin/basename $0)" containers=(minio grafana proxy titi) #----------------------------------------------------------------- # Functions #----------------------------------------------------------------- # display help function print_usage { # print /bin/cat << EOF Usage: $progName [options] Options: create Create container start Start stack '${COMPOSE_PROJECT_NAME}' stop Stop stack '${COMPOSE_PROJECT_NAME}' down Stop stack '${COMPOSE_PROJECT_NAME}' and delete containers restart Restart stack '${COMPOSE_PROJECT_NAME}' version,-v,--version Display script version help,-h,--help Display this help Examples: To start stack '${COMPOSE_PROJECT_NAME}' $progName start To stop stack '${COMPOSE_PROJECT_NAME}' $progName stop To create a new stack $progName create $progName start EOF } # read .env if exist if [ ! -f .env ]; then echo "file '.env' doesn't exist!" echo "See README.md" exit fi . .env #if [ ! -z "$1" ]; then #print_usage # exit 0 #fi case "$1" in create) docker compose create ;; start) for cont_item in "${containers[@]}"; do echo "Start container $cont_item" docker compose up -d $cont_item --remove-orphans echo $? done ;; down) docker compose down ;; -h|--help|help) print_usage exit 0 ;; -v|--version|version) echo $version ;; *) #echo "${progName}: invalid option -- '$1'!" #echo -e "Try '$progName help' for more information.\n" print_usage exit 0 ;; esac #!/bin/bash # Couleurs VERT="\e[32m" ROUGE="\e[31m" NORMAL="\e[0m" ## Message initial #echo "Lancement du conteneur..." # ## Exécution de la commande #if docker compose start toto > /dev/null 2>&1; then #echo -e "Lancement du conteneur : ${VERT}OK${NORMAL}" #else #echo -e "Lancement du conteneur : ${ROUGE}notOK${NORMAL}" #fi