Gilles Mouchet 04fbf6b547 #dev
2026-02-04 16:27:48 +01:00

126 lines
3.0 KiB
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
############################################################
# Decription: gestion docker compose
# Author: Gilles Mouchet (gilles.mouchet@gmail.com)
# Creation Date: 02.02.2026
# Version actuelle: 1.0.0
#
# Changelog:
# V1.0.0 - 02.02.2026 - GMo
# Ajouté
# - Création du script
#
############################################################
scriptName=$(basename "$0")
updateDate=02.02.2026
version=1.0.0
root_app=wp
RED='\e[1;31m'
GREEN='\e[0;32m'
ORANGE='\e[0;33m'
YELLOW='\e[1;33m'
BLUE='\e[0;34m'
PURPLE='\e[1;35m'
CYAN='\e[1;36m'
NC='\e[0m'
# Define functions to display usage information
version() {
cat<<EOF
${scriptName} - Version: $version ($updateDate) - Gilles Mouchet (gilles.mouchet@gmail.com)
Non-Commercial Use License See LICENSE for details
EOF
}
# Define functions to display usage information
usage() {
cat << EOF
Manage docker compose
${updateDate} - Version: $version - Gilles Mouchet (gilles.mouchet@geneve.ch)
Usage: $scriptName <options>
Options:
-a|--all stop docker compose, delete container and delete files in /home/docker/${root_app}
-e|--env environment (gmolab or vdglab)
-s|--stop stop docker compose
-u|--up start docker compose as daemon
-c|--console start docker compose as console
-d|--down stop docker compose and delete container
-v|--version version
-h|--help usage
EOF
}
#-----------------------------------------------------------
# MAIN
#-----------------------------------------------------------
# check for wich env the script run
environment=$(basename "${0%.*}") # delete extension
echo $environment
case $environment in
vdglab)
echo "environnement vdglab"
cp .env-vdglab .env
;;
*)
usage
;;
esac
# check param exist
if [ -z "$1" ]; then
usage
exit
fi
while [[ "$#" -gt 0 ]]; do
case "$1" in
-a|--all)
echo -e "${RED}-----------------------------------------------------------------------------------------------------"
echo -e "Do you really want to delete the contents of the /home/docker/${root_app} folder [y/N]?"
echo -e "----------------------------------------------------------------------------------------------------- ${NC}"
unset answer
read answer
if [ "${answer}" != "y" ]; then
echo -e "${ORANGE}Operation cancelled!${NC}"
exit 1
fi
docker compose down
#sleep 5
sudo rm -rf /home/docker/${root_app}/*
docker compose up -d
exit
;;
-s|stop)
docker compose stop
;;
-u|--up)
docker compose up -d
;;
-d|--down)
docker compose down
;;
-c|--console)
docker compose up
;;
-v|--version)
version
exit
;;
*|help|-h|--help)
usage
exit
;;
esac
shift
done