Add docker command to upgrade all containers

This commit is contained in:
2022-08-29 20:03:03 +02:00
parent 08ea805598
commit 71895a0029
2 changed files with 47 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
#!/usr/bin/env bash
## Mise à jour des container docker
readonly DOCKER_FOLDER="/srv/"
function ok()
{
echo -e "\e[32mdone\e[0m"
}
function failed()
{
echo -e "\e[31mfailed\e[0m"
}
function main() {
local container_list=$(find "${DOCKER_FOLDER}" -mindepth 1 -maxdepth 1 -type d ! -iname "archives" ! -iname "images" ! -iname "lost+found")
local container_updated=()
for container_path in ${container_list}; do
cd "${container_path}"
if [ -f docker-compose.yml ]; then
printf "Updating ${container_path} : \n" \
&& docker-compose pull \
&& docker-compose build --pull \
&& container_updated+=(${container_path}) \
&& ok \
|| failed
fi
cd - &>/dev/null
done
for container_path in ${container_updated[*]}; do
cd "${container_path}"
docker-compose down \
&& docker-compose stop \
&& docker-compose up -d
cd - &>/dev/null
done
}
main