diff --git a/install-release.sh b/install-release.sh index 0313525..2164215 100644 --- a/install-release.sh +++ b/install-release.sh @@ -243,11 +243,17 @@ get_version() { fi # Get V2Ray release version number TMP_FILE="$(mktemp)" - if ! curl -x "${PROXY}" -sS -H "Accept: application/vnd.github.v3+json" -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then + if ! curl -x "${PROXY}" -sS -i -H "Accept: application/vnd.github.v3+json" -o "$TMP_FILE" 'https://api.github.com/repos/v2fly/v2ray-core/releases/latest'; then "rm" "$TMP_FILE" echo 'error: Failed to get release list, please check your network.' exit 1 fi + HTTP_STATUS_CODE=$(awk 'NR==1 {print $2}' "$TMP_FILE") + if [[ $HTTP_STATUS_CODE -lt 200 ]] || [[ $HTTP_STATUS_CODE -gt 299 ]]; then + "rm" "$TMP_FILE" + echo "error: Failed to get release list, GitHub API response code: $HTTP_STATUS_CODE" + exit 1 + fi RELEASE_LATEST="$(sed 'y/,/\n/' "$TMP_FILE" | grep 'tag_name' | awk -F '"' '{print $4}')" "rm" "$TMP_FILE" RELEASE_VERSION="v${RELEASE_LATEST#v}"