Skip to content

Commit

Permalink
Fixed POSIX compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
V-Shadbolt committed Sep 25, 2024
1 parent 8b75534 commit e18253c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 14 deletions.
23 changes: 16 additions & 7 deletions images/strapi-alpine/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,26 @@ EOT
echo "$1" | awk -F. '{print $1, $2, $3}'
}

read current_major current_minor current_patch <<< $(get_version_parts "$current_strapi_version")
read image_major image_minor image_patch <<< $(get_version_parts "$STRAPI_VERSION")

if [ "$image_major" -eq "$current_major" ] && [ "$image_minor" -eq "$current_minor" ] && [ "$image_patch" -gt "$current_patch"]; then
version_parts=$(get_version_parts "$current_strapi_version")
set -- $version_parts
current_major=$1
current_minor=$2
current_patch=$3

version_parts=$(get_version_parts "$STRAPI_VERSION")
set -- $version_parts
image_major=$1
image_minor=$2
image_patch=$3

if [ "$image_major" -eq "$current_major" ] && [ "$image_minor" -eq "$current_minor" ] && [ "$image_patch" -gt "$current_patch" ]; then
echo "Patch upgrade needed: v${current_strapi_version} to v${image_major}.${image_minor}.${image_patch}. Upgrading..."
npx @strapi/upgrade patch -y || echo "Patch upgrade failed" && exit 1
npx @strapi/upgrade patch -y || { echo "Patch upgrade failed"; exit 1; }
fi

if [ "$image_major" -eq "$current_major" ] && [ "$image_minor" -gt "$current_minor" ]; then
echo "Minor upgrade needed: v${current_strapi_version} to v${image_major}.${image_minor}.${image_patch}. Upgrading..."
npx @strapi/upgrade minor -y || echo "Minor upgrade failed" && exit 1
npx @strapi/upgrade minor -y || { echo "Minor upgrade failed"; exit 1; }
fi

if [ "$image_major" -gt "$current_major" ]; then
Expand All @@ -160,7 +169,7 @@ EOT
npx @strapi/upgrade patch -y || echo "Patch upgrade failed or not needed, continuing..."
npx @strapi/upgrade minor -y || echo "Minor upgrade failed or not needed, continuing..."
echo "Performing major upgrade to v${image_major}..."
npx @strapi/upgrade major -y || echo "Major upgrade failed" && exit 1
npx @strapi/upgrade major -y || { echo "Major upgrade failed"; exit 1; }
fi
else
if [ -f "yarn.lock" ]; then
Expand Down
23 changes: 16 additions & 7 deletions images/strapi-debian/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,26 @@ EOT
echo "$1" | awk -F. '{print $1, $2, $3}'
}

read current_major current_minor current_patch <<< $(get_version_parts "$current_strapi_version")
read image_major image_minor image_patch <<< $(get_version_parts "$STRAPI_VERSION")

if [ "$image_major" -eq "$current_major" ] && [ "$image_minor" -eq "$current_minor" ] && [ "$image_patch" -gt "$current_patch"]; then
version_parts=$(get_version_parts "$current_strapi_version")
set -- $version_parts
current_major=$1
current_minor=$2
current_patch=$3

version_parts=$(get_version_parts "$STRAPI_VERSION")
set -- $version_parts
image_major=$1
image_minor=$2
image_patch=$3

if [ "$image_major" -eq "$current_major" ] && [ "$image_minor" -eq "$current_minor" ] && [ "$image_patch" -gt "$current_patch" ]; then
echo "Patch upgrade needed: v${current_strapi_version} to v${image_major}.${image_minor}.${image_patch}. Upgrading..."
npx @strapi/upgrade patch -y || echo "Patch upgrade failed" && exit 1
npx @strapi/upgrade patch -y || { echo "Patch upgrade failed"; exit 1; }
fi

if [ "$image_major" -eq "$current_major" ] && [ "$image_minor" -gt "$current_minor" ]; then
echo "Minor upgrade needed: v${current_strapi_version} to v${image_major}.${image_minor}.${image_patch}. Upgrading..."
npx @strapi/upgrade minor -y || echo "Minor upgrade failed" && exit 1
npx @strapi/upgrade minor -y || { echo "Minor upgrade failed"; exit 1; }
fi

if [ "$image_major" -gt "$current_major" ]; then
Expand All @@ -160,7 +169,7 @@ EOT
npx @strapi/upgrade patch -y || echo "Patch upgrade failed or not needed, continuing..."
npx @strapi/upgrade minor -y || echo "Minor upgrade failed or not needed, continuing..."
echo "Performing major upgrade to v${image_major}..."
npx @strapi/upgrade major -y || echo "Major upgrade failed" && exit 1
npx @strapi/upgrade major -y || { echo "Major upgrade failed"; exit 1; }
fi
else
if [ -f "yarn.lock" ]; then
Expand Down

0 comments on commit e18253c

Please sign in to comment.