Detect service names nicely
This commit is contained in:
@@ -38,6 +38,11 @@ flags()
|
|||||||
shift
|
shift
|
||||||
if [[ -d $CONTAINER_DIR/$1 ]]; then
|
if [[ -d $CONTAINER_DIR/$1 ]]; then
|
||||||
export CONTAINER_PATHS="$CONTAINER_DIR/$1"
|
export CONTAINER_PATHS="$CONTAINER_DIR/$1"
|
||||||
|
else
|
||||||
|
CONTAINER_PATHS="$(find /var/Red-Vol/Media/Containers/ -maxdepth 1 -type d -name "*$1*" | head -1)"
|
||||||
|
if [[ -n $CONTAINER_PATHS ]]; then
|
||||||
|
export CONTAINER_PATHS
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
shift;;
|
shift;;
|
||||||
(-v|--verbose|verbose)
|
(-v|--verbose|verbose)
|
||||||
@@ -98,6 +103,7 @@ for container_path in ${CONTAINER_PATHS[@]}; do
|
|||||||
debug "$container_image has tag" "$image_tag"
|
debug "$container_image has tag" "$image_tag"
|
||||||
export container_image=$(echo $container_image | awk -F: '{print $1}')
|
export container_image=$(echo $container_image | awk -F: '{print $1}')
|
||||||
# If the container does have a tag, keep the base name ^ without it (before the :)
|
# If the container does have a tag, keep the base name ^ without it (before the :)
|
||||||
|
export container_name=$(echo $container_name | awk -F: '{print $1}')
|
||||||
fi
|
fi
|
||||||
debug "Fetching local image checksum with:" "docker inspect \"$container_image$image_tag\" | grep -Eo \"($container_image@)?sha256:([0-9a-zA-Z].*)(\\\")\" | sed -e 's/\"//g' | awk -F@ '{print \$2}"
|
debug "Fetching local image checksum with:" "docker inspect \"$container_image$image_tag\" | grep -Eo \"($container_image@)?sha256:([0-9a-zA-Z].*)(\\\")\" | sed -e 's/\"//g' | awk -F@ '{print \$2}"
|
||||||
local_image=$(docker inspect "$container_image$image_tag" | grep -Eo "($container_image@)?sha256:([0-9a-zA-Z].*)(\")" | sed -e 's/"//g' -e 's/\s+//g' | awk -F@ '{print $2}')
|
local_image=$(docker inspect "$container_image$image_tag" | grep -Eo "($container_image@)?sha256:([0-9a-zA-Z].*)(\")" | sed -e 's/"//g' -e 's/\s+//g' | awk -F@ '{print $2}')
|
||||||
@@ -130,8 +136,9 @@ for container_path in ${CONTAINER_PATHS[@]}; do
|
|||||||
ok "$container_name" "is up to date!"
|
ok "$container_name" "is up to date!"
|
||||||
else
|
else
|
||||||
warn "$container_name" "is out of date!"
|
warn "$container_name" "is out of date!"
|
||||||
|
service=$(cat "$container_path/docker-compose.yml" | grep -B1 "$container_image" | head -1 | sed -e 's/^[ \t]*//' -e 's/://g')
|
||||||
info "Attempting to update" "$container_name"
|
info "Attempting to update" "$container_name"
|
||||||
if docker-compose pull $container_name; then
|
if docker-compose pull $service; then
|
||||||
info "Pulled latest image for" "$container_name"
|
info "Pulled latest image for" "$container_name"
|
||||||
if docker-compose up -d --remove-orphans; then
|
if docker-compose up -d --remove-orphans; then
|
||||||
ok "$container_stack" "has been updated sucessfully!"
|
ok "$container_stack" "has been updated sucessfully!"
|
||||||
|
|||||||
Reference in New Issue
Block a user