mirror of
https://github.com/xpipe-io/xpipe.git
synced 2024-11-21 23:20:23 +00:00
Script fixes
This commit is contained in:
parent
67eee13fca
commit
3180694f1b
1 changed files with 32 additions and 21 deletions
53
get-xpipe.sh
Normal file → Executable file
53
get-xpipe.sh
Normal file → Executable file
|
@ -1,11 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
release_url() {
|
||||
if [[ $# -eq 0 ]] ; then
|
||||
echo "https://github.com/xpipe-io/xpipe/releases/latest/download"
|
||||
local repo="$1"
|
||||
local version="$2"
|
||||
if [[ -z "$version" ]] ; then
|
||||
echo "$repo/releases/latest/download"
|
||||
else
|
||||
local version="$1"
|
||||
echo "https://github.com/xpipe-io/xpipe/releases/download/$version"
|
||||
echo "$repo/releases/download/$version"
|
||||
fi
|
||||
}
|
||||
|
||||
|
@ -31,15 +32,12 @@ get_file_ending() {
|
|||
download_release_from_repo() {
|
||||
local os_info="$1"
|
||||
local tmpdir="$2"
|
||||
local repo="$3"
|
||||
local version="$4"
|
||||
|
||||
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 release_url=$(release_url "$repo" "$version")
|
||||
|
||||
local filename="xpipe-installer-$os_info-$arch.$ending"
|
||||
local download_file="$tmpdir/$filename"
|
||||
|
@ -158,11 +156,9 @@ 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
|
||||
local repo="$1"
|
||||
local version="$2"
|
||||
download_release_from_repo "$os_info" "$download_dir" "$repo" "$version"
|
||||
}
|
||||
|
||||
check_architecture() {
|
||||
|
@ -190,12 +186,27 @@ return 0 2>/dev/null
|
|||
|
||||
check_architecture "$(uname -m)" || exit 1
|
||||
|
||||
repo="https://github.com/xpipe-io/xpipe"
|
||||
version=
|
||||
while getopts 'sv:' OPTION; do
|
||||
case "$OPTION" in
|
||||
s)
|
||||
repo="https://github.com/xpipe-io/xpipe_staging"
|
||||
;;
|
||||
|
||||
v)
|
||||
version="$OPTARG"
|
||||
;;
|
||||
|
||||
?)
|
||||
echo "Usage: $(basename $0) [-s] [-v <version>]"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
download_archive="$(
|
||||
if [[ $# -eq 1 ]] ; then
|
||||
download_release "$1"
|
||||
else
|
||||
download_release
|
||||
fi
|
||||
download_release "$repo" "$version"
|
||||
exit "$?"
|
||||
)"
|
||||
exit_status="$?"
|
||||
|
|
Loading…
Reference in a new issue