mirror of
https://github.com/meilisearch/meilisearch.git
synced 2024-11-22 18:17:39 +08:00
Fix error handler for curl command in script
This commit is contained in:
parent
f7e4a0177d
commit
c4a2d70d19
@ -73,7 +73,7 @@ semverLT() {
|
|||||||
get_latest() {
|
get_latest() {
|
||||||
temp_file='temp_file' # temp_file needed because the grep would start before the download is over
|
temp_file='temp_file' # temp_file needed because the grep would start before the download is over
|
||||||
|
|
||||||
if [ -z "$GITHUB_PAT" ]; then
|
if [ -z "$GITHUB_PAT" ]; then
|
||||||
curl -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file" || return 1
|
curl -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file" || return 1
|
||||||
else
|
else
|
||||||
curl -H "Authorization: token $GITHUB_PAT" -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file" || return 1
|
curl -H "Authorization: token $GITHUB_PAT" -s 'https://api.github.com/repos/meilisearch/meilisearch/releases' > "$temp_file" || return 1
|
||||||
@ -120,7 +120,7 @@ get_latest() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
rm -f "$temp_file"
|
rm -f "$temp_file"
|
||||||
echo $latest
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
# Gets the OS by setting the $os variable
|
# Gets the OS by setting the $os variable
|
||||||
@ -176,30 +176,41 @@ success_usage() {
|
|||||||
echo ' $ ./meilisearch --help'
|
echo ' $ ./meilisearch --help'
|
||||||
}
|
}
|
||||||
|
|
||||||
failure_usage() {
|
not_available_failure_usage() {
|
||||||
printf "$RED%s\n$DEFAULT" 'ERROR: Meilisearch binary is not available for your OS distribution or your architecture yet.'
|
printf "$RED%s\n$DEFAULT" 'ERROR: Meilisearch binary is not available for your OS distribution or your architecture yet.'
|
||||||
echo ''
|
echo ''
|
||||||
echo 'However, you can easily compile the binary from the source files.'
|
echo 'However, you can easily compile the binary from the source files.'
|
||||||
echo 'Follow the steps at the page ("Source" tab): https://docs.meilisearch.com/learn/getting_started/installation.html'
|
echo 'Follow the steps at the page ("Source" tab): https://docs.meilisearch.com/learn/getting_started/installation.html'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetch_release_failure_usage() {
|
||||||
|
echo ''
|
||||||
|
printf "$RED%s\n$DEFAULT" 'ERROR: Impossible to get the latest stable version of Meilisearch.'
|
||||||
|
echo 'Please let us know about this issue: https://github.com/meilisearch/meilisearch/issues/new/choose'
|
||||||
|
}
|
||||||
|
|
||||||
# MAIN
|
# MAIN
|
||||||
latest="$(get_latest)"
|
|
||||||
|
# Fill $latest variable
|
||||||
|
if ! get_latest; then
|
||||||
|
fetch_release_failure_usage # TO CHANGE
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
if [ "$latest" = '' ]; then
|
if [ "$latest" = '' ]; then
|
||||||
echo ''
|
fetch_release_failure_usage
|
||||||
echo 'Impossible to get the latest stable version of Meilisearch.'
|
|
||||||
echo 'Please let us know about this issue: https://github.com/meilisearch/meilisearch/issues/new/choose'
|
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Fill $os variable
|
||||||
if ! get_os; then
|
if ! get_os; then
|
||||||
failure_usage
|
not_available_failure_usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Fill $archi variable
|
||||||
if ! get_archi; then
|
if ! get_archi; then
|
||||||
failure_usage
|
not_available_failure_usage
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -207,16 +218,23 @@ echo "Downloading Meilisearch binary $latest for $os, architecture $archi..."
|
|||||||
case "$os" in
|
case "$os" in
|
||||||
'windows')
|
'windows')
|
||||||
release_file="meilisearch-$os-$archi.exe"
|
release_file="meilisearch-$os-$archi.exe"
|
||||||
binary_name='meilisearch.exe'
|
binary_name='meilisearch.exe'
|
||||||
|
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
release_file="meilisearch-$os-$archi"
|
release_file="meilisearch-$os-$archi"
|
||||||
binary_name='meilisearch'
|
binary_name='meilisearch'
|
||||||
|
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Fetch the Meilisearch binary
|
||||||
link="https://github.com/meilisearch/meilisearch/releases/download/$latest/$release_file"
|
link="https://github.com/meilisearch/meilisearch/releases/download/$latest/$release_file"
|
||||||
curl -OL "$link"
|
curl -OL "$link"
|
||||||
|
if [ $? -ne 0 ]
|
||||||
|
fetch_release_failure_usage
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
mv "$release_file" "$binary_name"
|
mv "$release_file" "$binary_name"
|
||||||
chmod 744 "$binary_name"
|
chmod 744 "$binary_name"
|
||||||
success_usage
|
success_usage
|
||||||
|
Loading…
Reference in New Issue
Block a user