File tree Expand file tree Collapse file tree 1 file changed +21
-10
lines changed
Expand file tree Collapse file tree 1 file changed +21
-10
lines changed Original file line number Diff line number Diff line change 22
33set -o errexit
44
5+ MONGOSH_RELEASES_URL=https://downloads.mongodb.com/compass/mongosh.json
6+
57for tool in jq curl; do
68 which " $tool " > /dev/null || {
79 echo >&2 " This script requires '$tool '."
@@ -25,24 +27,33 @@ case "$os" in
2527 exit 1
2628esac
2729
30+ # normalize $arch:
2831case " $arch " in
29- amd64|x86_64 )
30- arch=x64
32+ amd64|x64 )
33+ arch=x86_64
3134 ;;
3235 aarch64)
3336 arch=arm64
37+ ;;
38+ * )
39+ # Use uname’s reported architecture in the jq query.
3440esac
3541
36- urls=$( curl -fsSL https://api.github.com/repos/mongodb-js/mongosh/releases/latest | jq -r ' .assets[] | .browser_download_url' | grep -v -e \. sig -e shared -e openssl)
37- url=$( printf " %s" " $urls " | grep " \-${os} -${arch} " || :)
42+ jq_query=$( cat << EOF
43+ .versions[0].downloads[] |
44+ select(
45+ .distro == "$os " and
46+ .arch == "$arch " and
47+ (has("sharedOpenssl") | not)
48+ ) |
49+ .archive.url
50+ EOF
51+ )
3852
39- if [ -z " $url " ]; then
40- cat << EOL
41- No download found for $os on $arch ; download manually.
53+ url=$( curl -fsSL $MONGOSH_RELEASES_URL | jq -r " $jq_query " )
4254
43- URLs considered:
44- $urls
45- EOL
55+ if [ -z " $url " ]; then
56+ echo >&2 " No download found for $os on $arch ; download manually."
4657 exit 1
4758fi
4859
You can’t perform that action at this time.
0 commit comments