Update Docker Compose if possible.

This commit is contained in:
Buster "Silver Eagle" Neece 2021-06-27 00:33:58 -05:00
parent c94a9ac25d
commit 65dd8f143f
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
1 changed files with 18 additions and 2 deletions

View File

@ -1,6 +1,9 @@
#!/usr/bin/env bash
# shellcheck disable=SC2145,SC2178,SC2120,SC2162
# Constants
export COMPOSE_VERSION=1.29.2
# Functions to manage .env files
__dotenv=
__dotenv_file=
@ -116,6 +119,11 @@ yq() {
docker run --rm -i -v "${PWD}":/workdir mikefarah/yq "$@"
}
# Shortcut to convert semver version (x.yyy.zzz) into a comparable number.
version-number() {
echo "$@" | gawk -F. '{ printf("%03d%03d%03d\n", $1,$2,$3); }'
}
# This is a general-purpose function to ask Yes/No questions in Bash, either
# with or without a default answer. It keeps repeating the question until it
# gets a valid answer.
@ -234,8 +242,6 @@ install-docker() {
}
install-docker-compose() {
local COMPOSE_VERSION=1.29.2
if [[ $EUID -ne 0 ]]; then
if [[ ! $(command -v sudo) ]]; then
echo "Sudo does not appear to be installed."
@ -369,6 +375,16 @@ update() {
echo "Default environment file loaded."
fi
# Check for update to Docker Compose
local CURRENT_COMPOSE_VERSION
CURRENT_COMPOSE_VERSION=$(docker-compose version --short)
if [ "$(version-number "$COMPOSE_VERSION")" -gt "$(version-number "$CURRENT_COMPOSE_VERSION")" ]; then
if ask "Your version of Docker Compose is out of date. Attempt to update it automatically?" Y; then
install-docker-compose
fi
fi
# Migrate previous release settings to new environment variable.
.env --file azuracast.env get PREFER_RELEASE_BUILDS