Update install.func

This commit is contained in:
CanbiZ 2025-04-01 16:15:09 +02:00
parent 0670484b70
commit c39afae957

View File

@ -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