Updates and enhancements

This commit is contained in:
2023-03-17 13:32:30 +02:00
parent 97fb7da9b3
commit 2d9f26a558

View File

@@ -90,9 +90,10 @@ for container_path in ${CONTAINER_PATHS[@]}; do
# search for a pattern of something:something with optional :tag print ^ image name
for container_image in $container_images; do
debug "$container_stack has image" "$container_image"
debug "echo $container_image | awk -F/ '{print \$2}' | sed 's/\:.*//'"
container_name="$(echo $container_image | awk -F/ '{print $2}' | sed "s/\:.*//")"
# remove everything after the : ^
if [[ -z $container_name ]] && [[ -n $(echo $container_image | grep -Ev 'postgres|mariadb') ]]; then
if [[ -z $container_name ]]; then #&& [[ -n $(echo $container_image | grep -Ev 'postgres|mariadb') ]]; then
export container_name="$container_image"
fi
debug "$container_image has name" "$container_name"
@@ -136,8 +137,9 @@ for container_path in ${CONTAINER_PATHS[@]}; do
ok "$container_name" "is up to date!"
else
warn "$container_name" "is out of date!"
debug "cat \"$container_path/docker-compose.yml\" | grep -B1 "image: $container_image" | head -1 | sed -e 's/^[ \t]*//' -e 's/://g'"
service=$(cat "$container_path/docker-compose.yml" | grep -B1 "image: $container_image" | head -1 | sed -e 's/^[ \t]*//' -e 's/://g')
debug "cat \"$container_path/docker-compose.yml\" | grep -B1 \"image: $container_image\" | head -1 | sed -e 's/^[ \t]*//' -e 's/://g' | awk '{print \$NF}')"
service=$(cat "$container_path/docker-compose.yml" | grep -B1 "image: $container_image" | head -1 | sed -e 's/^[ \t]*//' -e 's/://g' | grep -v 'container_name')
# get container service name (1 line above image) ^ print service name^ ^ omit tabs and : and ^omit container_name
info "Attempting to update service" "$service"
if docker-compose pull $service; then
info "Pulled latest image for" "$container_name"