mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2026-07-30 17:52:54 +02:00
Update tools.func
This commit is contained in:
committed by
GitHub
parent
3a5a609c5f
commit
1d4d5d7e89
+20
-20
@@ -2736,8 +2736,8 @@ get_latest_gl_tag() {
|
||||
local repo_encoded
|
||||
repo_encoded=$(printf '%s' "$repo" | sed 's|/|%2F|g')
|
||||
|
||||
local gitlab_host="${GITLAB_HOST:-https://gitlab.com}"
|
||||
local api_base="${gitlab_host}/api/v4/projects/${repo_encoded}/repository/tags"
|
||||
local gitlab_url="${GITLAB_URL:-https://gitlab.com}"
|
||||
local api_base="${gitlab_url}/api/v4/projects/${repo_encoded}/repository/tags"
|
||||
local api_timeout="--connect-timeout 10 --max-time 60"
|
||||
|
||||
local header=()
|
||||
@@ -2819,7 +2819,7 @@ get_latest_gl_tag() {
|
||||
# Notes:
|
||||
# - Supports CLEAN_INSTALL=1 to wipe target before extracting
|
||||
# - Supports GITLAB_TOKEN for private/rate-limited projects
|
||||
# - Supports GITLAB_HOST for self-hosted GitLab (default: https://gitlab.com)
|
||||
# - Supports GITLAB_URL for self-hosted GitLab (default: https://gitlab.com)
|
||||
# - For repos that only publish tags, not formal GitLab Releases
|
||||
# (use fetch_and_deploy_gl_release for proper Releases with assets)
|
||||
# ------------------------------------------------------------------------------
|
||||
@@ -2863,9 +2863,9 @@ fetch_and_deploy_gl_tag() {
|
||||
repo_encoded=$(printf '%s' "$repo" | sed 's|/|%2F|g')
|
||||
|
||||
# GitLab source tarball URL (no release needed, works for any tag).
|
||||
local gitlab_host="${GITLAB_HOST:-https://gitlab.com}"
|
||||
local gitlab_url="${GITLAB_URL:-https://gitlab.com}"
|
||||
local version_safe="${resolved_tag//\//-}"
|
||||
local tarball_url="${gitlab_host}/${repo}/-/archive/${resolved_tag}/${app_lc}-${version_safe}.tar.gz"
|
||||
local tarball_url="${gitlab_url}/${repo}/-/archive/${resolved_tag}/${app_lc}-${version_safe}.tar.gz"
|
||||
|
||||
local tmpdir
|
||||
tmpdir=$(mktemp -d) || return 1
|
||||
@@ -9422,12 +9422,12 @@ get_latest_gitlab_release() {
|
||||
local temp_file
|
||||
temp_file=$(mktemp)
|
||||
|
||||
local gitlab_host="${GITLAB_HOST:-https://gitlab.com}"
|
||||
local gitlab_url="${GITLAB_URL:-https://gitlab.com}"
|
||||
local http_code
|
||||
http_code=$(curl --connect-timeout 10 --max-time 30 -sSL \
|
||||
-w "%{http_code}" -o "$temp_file" \
|
||||
"${header[@]}" \
|
||||
"${gitlab_host}/api/v4/projects/$repo_encoded/releases?per_page=1&order_by=released_at&sort=desc" 2>/dev/null) || true
|
||||
"${gitlab_url}/api/v4/projects/$repo_encoded/releases?per_page=1&order_by=released_at&sort=desc" 2>/dev/null) || true
|
||||
|
||||
if [[ "$http_code" != "200" ]]; then
|
||||
rm -f "$temp_file"
|
||||
@@ -9469,7 +9469,7 @@ get_latest_gitlab_release() {
|
||||
# Notes:
|
||||
# - Requires `jq` (auto-installed if missing)
|
||||
# - Supports GITLAB_TOKEN env var for private/rate-limited repos
|
||||
# - Supports GITLAB_HOST for self-hosted GitLab (default: https://gitlab.com)
|
||||
# - Supports GITLAB_URL for self-hosted GitLab (default: https://gitlab.com)
|
||||
# - Does not modify anything, only checks version state
|
||||
# ------------------------------------------------------------------------------
|
||||
check_for_gl_release() {
|
||||
@@ -9481,8 +9481,8 @@ check_for_gl_release() {
|
||||
local app_lc="${app,,}"
|
||||
local current_file="$HOME/.${app_lc}"
|
||||
|
||||
local gitlab_host="${GITLAB_HOST:-https://gitlab.com}"
|
||||
local gitlab_hostname="${gitlab_host#*://}"
|
||||
local gitlab_url="${GITLAB_URL:-https://gitlab.com}"
|
||||
local gitlab_hostname="${gitlab_url#*://}"
|
||||
gitlab_hostname="${gitlab_hostname%%/*}"
|
||||
|
||||
msg_info "Checking for update: ${app}"
|
||||
@@ -9512,7 +9512,7 @@ check_for_gl_release() {
|
||||
local pinned_encoded="${pinned_version_in//\//%2F}"
|
||||
http_code=$(curl -sSL --max-time 20 -w "%{http_code}" -o "$gl_check_json" \
|
||||
"${header[@]}" \
|
||||
"${gitlab_host}/api/v4/projects/$repo_encoded/releases/$pinned_encoded" 2>/dev/null) || true
|
||||
"${gitlab_url}/api/v4/projects/$repo_encoded/releases/$pinned_encoded" 2>/dev/null) || true
|
||||
if [[ "$http_code" == "200" ]] && [[ -s "$gl_check_json" ]]; then
|
||||
releases_json="[$(<"$gl_check_json")]"
|
||||
fi
|
||||
@@ -9523,7 +9523,7 @@ check_for_gl_release() {
|
||||
if [[ -z "$releases_json" ]]; then
|
||||
http_code=$(curl -sSL --max-time 20 -w "%{http_code}" -o "$gl_check_json" \
|
||||
"${header[@]}" \
|
||||
"${gitlab_host}/api/v4/projects/$repo_encoded/releases?per_page=100&order_by=released_at&sort=desc" 2>/dev/null) || true
|
||||
"${gitlab_url}/api/v4/projects/$repo_encoded/releases?per_page=100&order_by=released_at&sort=desc" 2>/dev/null) || true
|
||||
|
||||
if [[ "$http_code" == "200" ]] && [[ -s "$gl_check_json" ]]; then
|
||||
releases_json=$(<"$gl_check_json")
|
||||
@@ -9547,7 +9547,7 @@ check_for_gl_release() {
|
||||
return 22
|
||||
elif [[ "$http_code" == "000" || -z "$http_code" ]]; then
|
||||
msg_error "GitLab API connection failed (no response)."
|
||||
msg_error "Check your network/DNS: curl -sSL ${gitlab_host}/api/v4/version"
|
||||
msg_error "Check your network/DNS: curl -sSL ${gitlab_url}/api/v4/version"
|
||||
rm -f "$gl_check_json"
|
||||
return 7
|
||||
else
|
||||
@@ -9792,8 +9792,8 @@ fetch_and_deploy_gl_release() {
|
||||
local repo_encoded
|
||||
repo_encoded=$(printf '%s' "$repo" | sed 's|/|%2F|g')
|
||||
|
||||
local gitlab_host="${GITLAB_HOST:-https://gitlab.com}"
|
||||
local api_base="${gitlab_host}/api/v4/projects/$repo_encoded/releases"
|
||||
local gitlab_url="${GITLAB_URL:-https://gitlab.com}"
|
||||
local api_base="${gitlab_url}/api/v4/projects/$repo_encoded/releases"
|
||||
local api_url
|
||||
if [[ "$version" != "latest" ]]; then
|
||||
api_url="$api_base/$version"
|
||||
@@ -9842,7 +9842,7 @@ fetch_and_deploy_gl_release() {
|
||||
msg_error " export GITLAB_TOKEN=\"glpat-your_token_here\""
|
||||
elif [[ "$http_code" == "000" || -z "$http_code" ]]; then
|
||||
msg_error "GitLab API connection failed (no response)."
|
||||
msg_error "Check your network/DNS: curl -sSL ${gitlab_host}/api/v4/version"
|
||||
msg_error "Check your network/DNS: curl -sSL ${gitlab_url}/api/v4/version"
|
||||
else
|
||||
msg_error "Failed to fetch release metadata (HTTP $http_code)"
|
||||
fi
|
||||
@@ -9897,7 +9897,7 @@ fetch_and_deploy_gl_release() {
|
||||
|
||||
### Tarball Mode ###
|
||||
if [[ "$mode" == "tarball" || "$mode" == "source" ]]; then
|
||||
local direct_tarball_url="${gitlab_host}/$repo/-/archive/$tag_name/${app_lc}-${version_safe}.tar.gz"
|
||||
local direct_tarball_url="${gitlab_url}/$repo/-/archive/$tag_name/${app_lc}-${version_safe}.tar.gz"
|
||||
filename="${app_lc}-${version_safe}.tar.gz"
|
||||
|
||||
_download_source_tarball "$direct_tarball_url" "$tmpdir/$filename" "${header[@]}" || {
|
||||
@@ -9945,7 +9945,7 @@ fetch_and_deploy_gl_release() {
|
||||
|
||||
if [[ -z "$url_match" ]]; then
|
||||
local fallback_json
|
||||
if fallback_json=$(_gl_scan_older_releases "$repo" "$repo_encoded" "$gitlab_host" "binary" "$asset_pattern" "$tag_name"); then
|
||||
if fallback_json=$(_gl_scan_older_releases "$repo" "$repo_encoded" "$gitlab_url" "binary" "$asset_pattern" "$tag_name"); then
|
||||
json="$fallback_json"
|
||||
tag_name=$(echo "$json" | jq -r '.tag_name // empty')
|
||||
[[ "$tag_name" =~ ^v[0-9] ]] && version="${tag_name:1}" || version="$tag_name"
|
||||
@@ -10017,7 +10017,7 @@ fetch_and_deploy_gl_release() {
|
||||
|
||||
if [[ -z "$asset_url" ]]; then
|
||||
local fallback_json
|
||||
if fallback_json=$(_gl_scan_older_releases "$repo" "$repo_encoded" "$gitlab_host" "prebuild" "$pattern" "$tag_name"); then
|
||||
if fallback_json=$(_gl_scan_older_releases "$repo" "$repo_encoded" "$gitlab_url" "prebuild" "$pattern" "$tag_name"); then
|
||||
json="$fallback_json"
|
||||
tag_name=$(echo "$json" | jq -r '.tag_name // empty')
|
||||
[[ "$tag_name" =~ ^v[0-9] ]] && version="${tag_name:1}" || version="$tag_name"
|
||||
@@ -10070,7 +10070,7 @@ fetch_and_deploy_gl_release() {
|
||||
|
||||
if [[ -z "$asset_url" ]]; then
|
||||
local fallback_json
|
||||
if fallback_json=$(_gl_scan_older_releases "$repo" "$repo_encoded" "$gitlab_host" "singlefile" "$pattern" "$tag_name"); then
|
||||
if fallback_json=$(_gl_scan_older_releases "$repo" "$repo_encoded" "$gitlab_url" "singlefile" "$pattern" "$tag_name"); then
|
||||
json="$fallback_json"
|
||||
tag_name=$(echo "$json" | jq -r '.tag_name // empty')
|
||||
[[ "$tag_name" =~ ^v[0-9] ]] && version="${tag_name:1}" || version="$tag_name"
|
||||
|
||||
Reference in New Issue
Block a user