docker-scripts/docker-update-all

44 lines
962 B
Plaintext
Raw Permalink Normal View History

2023-02-08 19:46:00 +00:00
#!/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)
COMPOSE="docker compose"
;;
$COMPOSE_LEGACY)
COMPOSE="docker-compose"
;;
*)
echo "No docker-compose found."
exit 1
;;
esac
2023-02-08 19:46:00 +00:00
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
2023-02-08 19:46:00 +00:00
else
echo "Stack flagged for ignore updates"
fi
done
cd $START_DIR