change: replace download url with aliyun oss

This commit is contained in:
debugtalk
2022-01-20 18:15:53 +08:00
parent a898adb651
commit db596b13ca
3 changed files with 25 additions and 5 deletions

View File

@@ -1,6 +1,6 @@
#!/bin/bash
# install hrp with one shell command
# bash -c "$(curl -ksSL https://raw.githubusercontent.com/httprunner/hrp/main/cli/scripts/install.sh)"
# bash -c "$(curl -ksSL https://httprunner.oss-cn-beijing.aliyuncs.com/install.sh)"
set -e
@@ -24,6 +24,11 @@ function get_latest_version() {
curl -sL https://github.com/httprunner/hrp/releases/latest | grep '<title>Release' | cut -d" " -f4
}
function get_os() {
os=$(uname -s)
echo "$os" | tr '[:upper:]' '[:lower:]'
}
function get_arch() {
arch=$(uname -m)
if [ "$arch" == "x86_64" ]; then
@@ -32,16 +37,24 @@ function get_arch() {
echo "$arch"
}
function get_download_url() {
# github
# url="https://github.com/httprunner/hrp/releases/download/$version/$1"
# aliyun oss
url="https://httprunner.oss-cn-beijing.aliyuncs.com/$1"
echo $url
}
function main() {
echoInfo "Detect target hrp package..."
version=$(get_latest_version)
echo "Latest version: $version"
os=$(uname -s)
os=$(get_os)
echo "Current OS: $os"
arch=$(get_arch)
echo "Current ARCH: $arch"
pkg="hrp-$version-$os-$arch.tar.gz"
url="https://github.com/httprunner/hrp/releases/download/$version/$pkg"
url=$(get_download_url $pkg)
echo "Selected package: $url"
echo