docker-scripts/docker-update-all
bkraul f5d8b3422a Added countdown time to docker-stack-rm.
Added check for compose plugin and legacy docker-compose.
2023-06-16 18:13:11 -05:00

46 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
COMPOSE_PLUGIN=$(docker compose >/dev/null 2>&1; if [ "$?" == "0" ]; then echo "true"; else echo "false"; fi)
COMPOSE_LEGACY=$(docker-compose >/dev/null 2>&1; if [ "$?" == "0" ]; then echo "true"; else echo "false"; fi)
case "true" in
$COMPOSE_PLUGIN)
echo "using docker compose"
COMPOSE="docker compose"
;;
$COMPOSE_LEGACY)
echo "using docker-compose"
COMPOSE="docker-compose"
;;
*)
echo "No docker-compose found."
exit 1
;;
esac
if [ ! -z $1 ]; then
START_DIR="$1"
else
START_DIR="$HOME/docker-compose"
fi
if [ ! -d "$START_DIR" ]; then
echo "Invalid directory '$START_DIR': Exiting."
exit 1
fi
echo "Current dir is $START_DIR"
for f in $(find $START_DIR/ -iname "docker-compose.yml")
do
CURRENT_DIR=$(dirname "${f}")
echo "Updating $CURRENT_DIR..."
cd $CURRENT_DIR
if [ ! -f ".update.ignore" ]; then
$COMPOSE pull --no-parallel && $COMPOSE up -d --remove-orphans 2>&1
else
echo "Stack flagged for ignore updates"
fi
done
cd $START_DIR