From c39afae9578e0c4f74be3760a6e117dc4a7e8aad Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 1 Apr 2025 16:15:09 +0200 Subject: [PATCH] Update install.func --- misc/install.func | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/misc/install.func b/misc/install.func index 096d0fa..6ec0296 100644 --- a/misc/install.func +++ b/misc/install.func @@ -222,7 +222,7 @@ EOF get_gh_release() { local repo="$1" - local app="$2" + local app="${repo##*/}" # extract the app name from the repo URL local api_url="https://api.github.com/repos/$repo/releases/latest" local header=() local attempt=0 @@ -231,7 +231,6 @@ get_gh_release() { [[ -n "$GITHUB_TOKEN" ]] && header=(-H "Authorization: token $GITHUB_TOKEN") - # Retry loop until [[ $attempt -ge $max_attempts ]]; do ((attempt++)) msg_info "[$attempt/$max_attempts] Fetching GitHub release for $repo" @@ -241,13 +240,11 @@ get_gh_release() { continue fi - # Check for rate limit if echo "$api_response" | grep -q "API rate limit exceeded"; then msg_error "GitHub API rate limit exceeded. Set GITHUB_TOKEN to increase limit." return 1 fi - # Check if repo not found if echo "$api_response" | jq -e '.message == "Not Found"' &>/dev/null; then msg_error "Repository not found: $repo" return 1 @@ -264,11 +261,11 @@ get_gh_release() { msg_ok "Found release: $tag for $repo" - # Save version file if not exists + # save version to file local version_file="/opt/${app}_version.txt" [[ ! -f "$version_file" ]] && echo "$tag" >"$version_file" - # Download tarball + # Download and extract local temp_file temp_file=$(mktemp) local tarball_url="https://github.com/$repo/archive/refs/tags/v$tag.tar.gz" @@ -280,8 +277,8 @@ get_gh_release() { mkdir -p "/opt/$app" tar -xzf "$temp_file" -C /opt - mv /opt/"$(basename "$repo")-$tag"/* "/opt/$app/" 2>/dev/null - rm -rf "/opt/$(basename "$repo")-$tag" + mv "/opt/${app}-${tag}"/* "/opt/$app/" 2>/dev/null || msg_warn "Could not move extracted files." + rm -rf "/opt/${app}-${tag}" echo "$tag" return 0