From 28591895f035c274882c7ce08d96b6bbf67f1d84 Mon Sep 17 00:00:00 2001 From: CanbiZ <47820557+MickLesk@users.noreply.github.com> Date: Tue, 1 Apr 2025 16:36:41 +0200 Subject: [PATCH] Update install.func --- misc/install.func | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/misc/install.func b/misc/install.func index 2082183..01b1522 100644 --- a/misc/install.func +++ b/misc/install.func @@ -268,21 +268,6 @@ get_gh_release() { local version_file="/opt/${app}_version.txt" [[ ! -f "$version_file" ]] && echo "$tag" >"$version_file" - local temp_file - temp_file=$(mktemp) - local tarball_url="https://github.com/$repo/archive/refs/tags/v$tag.tar.gz" - msg_info "Downloading tarball..." - - if ! curl -fsSL "$tarball_url" -o "$temp_file"; then - msg_error "Failed to download tarball: $tarball_url" - return 1 - fi - - mkdir -p "/opt/$app" - tar -xzf "$temp_file" -C /opt - 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 done @@ -291,6 +276,32 @@ get_gh_release() { return 1 } +fetch_and_extract_gh_release() { + set -Eeuo pipefail + trap 'echo -e "\n❌ [fetch_and_extract_gh_release] Error on line $LINENO: $BASH_COMMAND"' ERR + + local repo="$1" + local tag="$2" + local app="${repo##*/}" + + 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 $app..." + if ! curl -fsSL "$tarball_url" -o "$temp_file"; then + msg_error "Failed to download tarball: $tarball_url" + return 1 + fi + + mkdir -p "/opt/$app" + tar -xzf "$temp_file" -C /opt + mv "/opt/${app}-${tag}"/* "/opt/$app/" 2>/dev/null || msg_warn "Could not move extracted files." + rm -rf "/opt/${app}-${tag}" + + msg_ok "Extracted $app to /opt/$app" +} + # This function modifies the message of the day (motd) and SSH settings motd_ssh() { grep -qxF "export TERM='xterm-256color'" /root/.bashrc || echo "export TERM='xterm-256color'" >>/root/.bashrc