mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-22 07:30:24 +00:00
Improve download script
This commit is contained in:
parent
623d6be4ad
commit
a2e04a24e6
1 changed files with 24 additions and 4 deletions
22
get-xpipe.sh
22
get-xpipe.sh
|
@ -1,7 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
release_url() {
|
||||
if [[ $# -eq 0 ]] ; then
|
||||
echo "https://github.com/xpipe-io/xpipe/releases/latest/download"
|
||||
else
|
||||
local version="$1"
|
||||
echo "https://github.com/xpipe-io/xpipe/releases/download/$version"
|
||||
fi
|
||||
}
|
||||
|
||||
get_file_ending() {
|
||||
|
@ -28,10 +33,17 @@ download_release_from_repo() {
|
|||
local tmpdir="$2"
|
||||
local ending=$(get_file_ending)
|
||||
local arch="$(uname -m)"
|
||||
local release_url
|
||||
|
||||
if [[ $# -eq 3 ]] ; then
|
||||
release_url=$(release_url "$3")
|
||||
else
|
||||
release_url=$(release_url)
|
||||
fi
|
||||
|
||||
local filename="xpipe-installer-$os_info-$arch.$ending"
|
||||
local download_file="$tmpdir/$filename"
|
||||
local archive_url="$(release_url)/$filename"
|
||||
local archive_url="$release_url/$filename"
|
||||
|
||||
info "Downloading file $archive_url"
|
||||
curl --progress-bar --show-error --location --fail "$archive_url" --output "$download_file" --write-out "$download_file"
|
||||
|
@ -146,7 +158,11 @@ download_release() {
|
|||
|
||||
# store the downloaded archive in a temporary directory
|
||||
local download_dir="$(mktemp -d)"
|
||||
if [[ $# -eq 1 ]] ; then
|
||||
download_release_from_repo "$os_info" "$download_dir" "$1"
|
||||
else
|
||||
download_release_from_repo "$os_info" "$download_dir"
|
||||
fi
|
||||
}
|
||||
|
||||
check_architecture() {
|
||||
|
@ -175,7 +191,11 @@ return 0 2>/dev/null
|
|||
check_architecture "$(uname -m)" || exit 1
|
||||
|
||||
download_archive="$(
|
||||
if [[ $# -eq 1 ]] ; then
|
||||
download_release "$1"
|
||||
else
|
||||
download_release
|
||||
fi
|
||||
exit "$?"
|
||||
)"
|
||||
exit_status="$?"
|
||||
|
|
Loading…
Reference in a new issue