45 lines
890 B
Bash
Executable File
45 lines
890 B
Bash
Executable File
#!/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
|