1
0

feat: add script to update docker containers deployed by "docker compose"

This commit is contained in:
2025-05-11 21:37:02 +02:00
parent 00104ab1ba
commit 602bce164d

View File

@@ -0,0 +1,41 @@
#!/usr/bin/bash
if [ $(id -u) -ne 0 ]; then
echo "This script must be run as root user"
exit 1
fi
if [ -z $1 ]; then
echo "Usage $0 <service 1> [<service 2> ...]"
exit 1
fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
function update_service {
SERVICE=$1
if [ ! -d "$SCRIPT_DIR/$1" ]; then
echo "Service $SERVICE does not exist"
return 1
fi
DIRECTORY="$SCRIPT_DIR/$SERVICE"
COMPOSE_FILE=`find $DIRECTORY -maxdepth 1 -type f -iname "*compose.y*ml"`
if [ $? -ne 0 ]; then
echo "No docker compose has been found on directory $DIRECTORY"
return 1
fi
docker compose -f $COMPOSE_FILE pull
docker compose -f $COMPOSE_FILE up -d
}
while
SERVICE=$1
shift
update_service $SERVICE
[[ -n "$1" ]]
do true; done