Update install.func

This commit is contained in:
CanbiZ 2025-04-01 16:24:09 +02:00
parent c39afae957
commit f5a5b93b2e

View File

@ -222,7 +222,7 @@ EOF
get_gh_release() {
local repo="$1"
local app="${repo##*/}" # extract the app name from the repo URL
local app="${repo##*/}"
local api_url="https://api.github.com/repos/$repo/releases/latest"
local header=()
local attempt=0
@ -234,6 +234,7 @@ get_gh_release() {
until [[ $attempt -ge $max_attempts ]]; do
((attempt++))
msg_info "[$attempt/$max_attempts] Fetching GitHub release for $repo"
if ! api_response=$(curl -fsSL "${header[@]}" "$api_url"); then
msg_warn "Request failed for $repo, retrying..."
sleep 2
@ -241,7 +242,7 @@ get_gh_release() {
fi
if echo "$api_response" | grep -q "API rate limit exceeded"; then
msg_error "GitHub API rate limit exceeded. Set GITHUB_TOKEN to increase limit."
msg_error "GitHub API rate limit exceeded."
return 1
fi
@ -261,15 +262,14 @@ get_gh_release() {
msg_ok "Found release: $tag for $repo"
# save version to file
local version_file="/opt/${app}_version.txt"
[[ ! -f "$version_file" ]] && echo "$tag" >"$version_file"
# Download and extract
local temp_file
temp_file=$(mktemp)
local tarball_url="https://github.com/$repo/archive/refs/tags/v$tag.tar.gz"
msg_info "Downloading tarball for $repo..."
msg_info "Downloading tarball..."
if ! curl -fsSL "$tarball_url" -o "$temp_file"; then
msg_error "Failed to download tarball: $tarball_url"
return 1