Skip to content

Commit

Permalink
chore(docker-monolithic): reformat file
Browse files Browse the repository at this point in the history
  • Loading branch information
bytestream committed Oct 25, 2024
1 parent 94675ec commit 2bcf6f2
Showing 1 changed file with 38 additions and 32 deletions.
70 changes: 38 additions & 32 deletions templates/docker-monolithic/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,42 +9,48 @@ usage="Options:
ref=5.x

while [[ "$#" -gt 0 ]]; do
case $1 in
-h|--help) echo "$usage" ; exit 0 ;;
-r|--ref) ref="$2" ; shift ;;
*)
echo "Unknown parameter passed: $1"
exit 1
;;
esac
shift
case $1 in
-h | --help)
echo "$usage"
exit 0
;;
-r | --ref)
ref="$2"
shift
;;
*)
echo "Unknown parameter passed: $1"
exit 1
;;
esac
shift
done

# usage: version_ge <installed_version> <minimum_version>
version_ge() {
if ! [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]; then
printf "error: %s is less than minimum required version of %s\n" "$1" "$2"
exit 1
fi
if ! [ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]; then
printf "error: %s is less than minimum required version of %s\n" "$1" "$2"
exit 1
fi
}

check_docker_compose() {
local min="2.2.1" version command_status

set +e
version="$(docker compose version --short 2>&1)"
command_status="$?"
set -e

if [ $command_status -ne 0 ]; then
printf "error: Install docker compose using the official installation instructions: https://docs.docker.com/compose/install/\n"
exit 1
fi

version="${version#v}"
printf "checking docker compose version %s >= %s ... " "$version" "$min"
version_ge "$version" "$min"
printf "✔\n"
local min="2.2.1" version command_status

set +e
version="$(docker compose version --short 2>&1)"
command_status="$?"
set -e

if [ $command_status -ne 0 ]; then
printf "error: Install docker compose using the official installation instructions: https://docs.docker.com/compose/install/\n"
exit 1
fi

version="${version#v}"
printf "checking docker compose version %s >= %s ... " "$version" "$min"
version_ge "$version" "$min"
printf "✔\n"
}

backup_config() {
Expand Down Expand Up @@ -74,9 +80,9 @@ migrate_hostname() {
}

update_env() {
if ! grep -qs 'DOMAIN_NAME=' .env; then
migrate_hostname
fi
if ! grep -qs 'DOMAIN_NAME=' .env; then
migrate_hostname
fi
}

upgrade() {
Expand Down

0 comments on commit 2bcf6f2

Please sign in to comment.