Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Automated] Merge 5.x into master #218

Merged
merged 3 commits into from
Oct 28, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 49 additions & 39 deletions templates/docker-monolithic/upgrade.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,47 +9,53 @@ 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() {
time_now=$(date +"%d-%m-%Y-%H:%M:%S")
cp --update=none docker-compose.yml "docker-compose.backup-${time_now}.yml"
cp -n docker-compose.yml "docker-compose.backup-${time_now}.yml"
}

update_compose_files() {
Expand All @@ -61,18 +67,22 @@ update_volumes() {
}

migrate_hostname() {
grep "hostname" docker-compose.override.yml | xargs | sed "s/hostname: /DOMAIN_NAME=/" >> .env
if [[ "$(uname -s)" == Darwin ]]; then
sed -i "" -e "s/hostname:.*/hostname: ''/" docker-compose.override.yml
else
sed -i -e "s/hostname:.*/hostname: ''/" docker-compose.override.yml
fi
if [ ! -f docker-compose.override.yml ]; then
return
fi

grep "hostname" docker-compose.override.yml | xargs | sed "s/hostname: /DOMAIN_NAME=/" >>.env
if [[ "$(uname -s)" == Darwin ]]; then
sed -i "" -e "s/hostname:.*/hostname: ''/" docker-compose.override.yml
else
sed -i -e "s/hostname:.*/hostname: ''/" docker-compose.override.yml
fi
}

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
Loading