mirror of
https://github.com/community-scripts/ProxmoxVE.git
synced 2025-11-09 04:42:51 +00:00
Compare commits
2 Commits
update_ver
...
MickLesk-p
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1c2b9d2513 | ||
|
|
34dac86b4b |
@@ -1198,8 +1198,8 @@ ensure_apt_working() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# Standardized deb822 repository setup
|
# Standardized deb822 repository setup (with optional Architectures)
|
||||||
# Validates all parameters and fails safely if any are empty
|
# Always runs apt update after repo creation to ensure package availability
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
setup_deb822_repo() {
|
setup_deb822_repo() {
|
||||||
local name="$1"
|
local name="$1"
|
||||||
@@ -1207,56 +1207,40 @@ setup_deb822_repo() {
|
|||||||
local repo_url="$3"
|
local repo_url="$3"
|
||||||
local suite="$4"
|
local suite="$4"
|
||||||
local component="${5:-main}"
|
local component="${5:-main}"
|
||||||
local architectures="${6:-$(dpkg --print-architecture)}"
|
local architectures="$6" # optional
|
||||||
|
|
||||||
# Validate required parameters
|
# Validate required parameters
|
||||||
if [[ -z "$name" || -z "$gpg_url" || -z "$repo_url" || -z "$suite" ]]; then
|
if [[ -z "$name" || -z "$gpg_url" || -z "$repo_url" || -z "$suite" ]]; then
|
||||||
msg_error "setup_deb822_repo: missing required parameters (name=$name, gpg=$gpg_url, repo=$repo_url, suite=$suite)"
|
msg_error "setup_deb822_repo: missing required parameters (name=$name repo=$repo_url suite=$suite)"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cleanup old configs for this app
|
# Cleanup
|
||||||
cleanup_old_repo_files "$name"
|
cleanup_old_repo_files "$name"
|
||||||
|
|
||||||
# Cleanup any orphaned .sources files from other apps
|
|
||||||
cleanup_orphaned_sources
|
cleanup_orphaned_sources
|
||||||
|
|
||||||
# Ensure keyring directory exists
|
|
||||||
mkdir -p /etc/apt/keyrings || {
|
mkdir -p /etc/apt/keyrings || {
|
||||||
msg_error "Failed to create /etc/apt/keyrings directory"
|
msg_error "Failed to create /etc/apt/keyrings"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Download GPG key (with --yes to avoid interactive prompts)
|
# Import GPG
|
||||||
curl -fsSL "$gpg_url" | gpg --dearmor --yes -o "/etc/apt/keyrings/${name}.gpg" 2>/dev/null || {
|
curl -fsSL "$gpg_url" | gpg --dearmor --yes -o "/etc/apt/keyrings/${name}.gpg" || {
|
||||||
msg_error "Failed to download or import GPG key for ${name} from $gpg_url"
|
msg_error "Failed to import GPG key for ${name}"
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create deb822 sources file
|
# Write deb822
|
||||||
cat <<EOF >/etc/apt/sources.list.d/${name}.sources
|
{
|
||||||
Types: deb
|
echo "Types: deb"
|
||||||
URIs: $repo_url
|
echo "URIs: $repo_url"
|
||||||
Suites: $suite
|
echo "Suites: $suite"
|
||||||
Components: $component
|
echo "Components: $component"
|
||||||
Architectures: $architectures
|
[[ -n "$architectures" ]] && echo "Architectures: $architectures"
|
||||||
Signed-By: /etc/apt/keyrings/${name}.gpg
|
echo "Signed-By: /etc/apt/keyrings/${name}.gpg"
|
||||||
EOF
|
} >/etc/apt/sources.list.d/${name}.sources
|
||||||
|
|
||||||
# Use cached apt update
|
$STD apt update
|
||||||
local apt_cache_file="/var/cache/apt-update-timestamp"
|
|
||||||
local current_time=$(date +%s)
|
|
||||||
local last_update=0
|
|
||||||
|
|
||||||
if [[ -f "$apt_cache_file" ]]; then
|
|
||||||
last_update=$(cat "$apt_cache_file" 2>/dev/null || echo 0)
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For repo changes, always update but respect short-term cache (30s)
|
|
||||||
if ((current_time - last_update > 30)); then
|
|
||||||
$STD apt update
|
|
||||||
echo "$current_time" >"$apt_cache_file"
|
|
||||||
fi
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|||||||
Reference in New Issue
Block a user