diff --git a/.bin/docker-upgrade-all-containers b/.bin/docker-upgrade-all-containers new file mode 100755 index 0000000..c84068f --- /dev/null +++ b/.bin/docker-upgrade-all-containers @@ -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 diff --git a/.config/fish/functions/docker-upgrade-all-containers.fish b/.config/fish/functions/docker-upgrade-all-containers.fish new file mode 100644 index 0000000..06c8bfa --- /dev/null +++ b/.config/fish/functions/docker-upgrade-all-containers.fish @@ -0,0 +1,3 @@ +function docker-upgrade-all-containers + bash "$HOME/.bin/docker-upgrade-all-containers" +end