Cleanup MSG's
Some checks failed
Bump build.func Revision / bump-revision (push) Has been cancelled

This commit is contained in:
CanbiZ 2025-10-22 13:52:17 +02:00
parent d51e669a9d
commit 61e3721c1d
2 changed files with 105 additions and 134 deletions

View File

@ -2988,82 +2988,83 @@ create_lxc_container() {
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
# Template discovery & validation # Template discovery & validation
# Simple approach: var_os (alpine/ubuntu/debian) + var_version (24.04/11/12/13/22.04)
# 1. Check local storage
# 2. Check for newer version in pveam
# 3. If not found at all, offer alternatives
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
msg_info "Finding template for ${PCT_OSTYPE} ${PCT_OSVERSION}" TEMPLATE_SEARCH="${PCT_OSTYPE}-${PCT_OSVERSION:-}"
# Determine template pattern based on OS
case "$PCT_OSTYPE" in case "$PCT_OSTYPE" in
debian | ubuntu) TEMPLATE_PATTERN="-standard_" ;; debian | ubuntu) TEMPLATE_PATTERN="-standard_" ;;
alpine | fedora | rocky | centos) TEMPLATE_PATTERN="-default_" ;; alpine | fedora | rocky | centos) TEMPLATE_PATTERN="-default_" ;;
*) TEMPLATE_PATTERN="-" ;; *) TEMPLATE_PATTERN="" ;;
esac esac
# Step 1: Search in local storage msg_info "Searching for template '$TEMPLATE_SEARCH'"
LOCAL_TEMPLATE=$(pveam list "$TEMPLATE_STORAGE" 2>/dev/null | awk '{print $NF}' | grep "^${PCT_OSTYPE}-${PCT_OSVERSION}.*${TEMPLATE_PATTERN}" | sort -V | tail -1)
# Step 2: Check pveam for available version (could be newer) # Build regex patterns outside awk/grep for clarity
ONLINE_TEMPLATE=$(pveam available -section system 2>/dev/null | awk '{print $NF}' | grep "^${PCT_OSTYPE}-${PCT_OSVERSION}.*${TEMPLATE_PATTERN}" | sort -V | tail -1) SEARCH_PATTERN="^${TEMPLATE_SEARCH}-"
# Decide what to use echo "[DEBUG] TEMPLATE_SEARCH='$TEMPLATE_SEARCH'"
if [[ -n "$LOCAL_TEMPLATE" && -n "$ONLINE_TEMPLATE" ]]; then echo "[DEBUG] SEARCH_PATTERN='$SEARCH_PATTERN'"
# Both exist - check if online is newer echo "[DEBUG] TEMPLATE_PATTERN='$TEMPLATE_PATTERN'"
if [[ "$LOCAL_TEMPLATE" != "$ONLINE_TEMPLATE" ]]; then
msg_info "Local template: $LOCAL_TEMPLATE" mapfile -t LOCAL_TEMPLATES < <(
msg_info "Newer version available: $ONLINE_TEMPLATE" pveam list "$TEMPLATE_STORAGE" 2>/dev/null |
echo "" awk -v search="${SEARCH_PATTERN}" -v pattern="${TEMPLATE_PATTERN}" '$1 ~ search && $1 ~ pattern {print $1}' |
read -p "Download newer version? [y/N]: " answer sed 's|.*/||' | sort -t - -k 2 -V
case "${answer,,}" in )
y | yes)
TEMPLATE="$ONLINE_TEMPLATE" pveam update >/dev/null 2>&1 || msg_warn "Could not update template catalog (pveam update failed)."
TEMPLATE_SOURCE="online"
msg_ok "Using newer version: $TEMPLATE" echo "[DEBUG] pveam available output (first 5 lines with .tar files):"
;; pveam available -section system 2>/dev/null | grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | head -5 | sed 's/^/ /'
*)
TEMPLATE="$LOCAL_TEMPLATE" mapfile -t ONLINE_TEMPLATES \
TEMPLATE_SOURCE="local" \
msg_ok "Using local version: $TEMPLATE" echo "[DEBUG] After filtering: ${#ONLINE_TEMPLATES[@]} online templates found" < <(pveam available -section system 2>/dev/null | grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | awk -F'\t' '{print $1}' | grep -E "${SEARCH_PATTERN}.*${TEMPLATE_PATTERN}" | sort -t - -k 2 -V 2>/dev/null || true)
;; if [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]]; then
esac echo "[DEBUG] Online templates:"
else for tmpl in "${ONLINE_TEMPLATES[@]}"; do
# Same version echo " - $tmpl"
TEMPLATE="$LOCAL_TEMPLATE" done
TEMPLATE_SOURCE="local"
msg_ok "Using local template: $TEMPLATE"
fi fi
elif [[ -n "$LOCAL_TEMPLATE" ]]; then
# Only local exists ONLINE_TEMPLATE=""
TEMPLATE="$LOCAL_TEMPLATE" [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]] && ONLINE_TEMPLATE="${ONLINE_TEMPLATES[-1]}"
msg_debug "SEARCH_PATTERN='${SEARCH_PATTERN}' TEMPLATE_PATTERN='${TEMPLATE_PATTERN}'"
msg_debug "Found ${#LOCAL_TEMPLATES[@]} local templates, ${#ONLINE_TEMPLATES[@]} online templates"
if [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]]; then
msg_debug "First 3 online templates:"
for i in {0..2}; do
[[ -n "${ONLINE_TEMPLATES[$i]}" ]] && msg_debug " [$i]: ${ONLINE_TEMPLATES[$i]}"
done
fi
msg_debug "ONLINE_TEMPLATE='$ONLINE_TEMPLATE'"
if [[ ${#LOCAL_TEMPLATES[@]} -gt 0 ]]; then
TEMPLATE="${LOCAL_TEMPLATES[-1]}"
TEMPLATE_SOURCE="local" TEMPLATE_SOURCE="local"
msg_ok "Using local template: $TEMPLATE" else
elif [[ -n "$ONLINE_TEMPLATE" ]]; then
# Only online exists
TEMPLATE="$ONLINE_TEMPLATE" TEMPLATE="$ONLINE_TEMPLATE"
TEMPLATE_SOURCE="online" TEMPLATE_SOURCE="online"
msg_ok "Template found online: $TEMPLATE" fi
else
# Nothing found - offer alternatives
msg_error "Template not found for ${PCT_OSTYPE} ${PCT_OSVERSION}"
echo ""
echo "This could mean:"
echo " • The version is not yet available in the Proxmox template repository"
echo " • Your Proxmox VE might need an update to access newer templates"
echo " • The version number might be incorrect"
# If still no template, try to find alternatives
if [[ -z "$TEMPLATE" ]]; then
echo ""
echo "[DEBUG] No template found for ${PCT_OSTYPE} ${PCT_OSVERSION}, searching for alternatives..."
# Get all available versions for this OS type
mapfile -t AVAILABLE_VERSIONS < <( mapfile -t AVAILABLE_VERSIONS < <(
pveam available -section system 2>/dev/null | pveam available -section system 2>/dev/null |
awk '{print $NF}' | grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' |
awk -F'\t' '{print $1}' |
grep "^${PCT_OSTYPE}-" | grep "^${PCT_OSTYPE}-" |
sed -E "s/.*${PCT_OSTYPE}-([0-9]+(\.[0-9]+)?).*/\1/" | sed -E "s/.*${PCT_OSTYPE}-([0-9]+(\.[0-9]+)?).*/\1/" |
sort -u -V sort -u -V 2>/dev/null
) )
if [[ ${#AVAILABLE_VERSIONS[@]} -gt 0 ]]; then if [[ ${#AVAILABLE_VERSIONS[@]} -gt 0 ]]; then
echo "" echo ""
msg_info "Available ${PCT_OSTYPE} versions:" echo "${BL}Available ${PCT_OSTYPE} versions:${CL}"
for i in "${!AVAILABLE_VERSIONS[@]}"; do for i in "${!AVAILABLE_VERSIONS[@]}"; do
echo " [$((i + 1))] ${AVAILABLE_VERSIONS[$i]}" echo " [$((i + 1))] ${AVAILABLE_VERSIONS[$i]}"
done done
@ -3072,12 +3073,25 @@ create_lxc_container() {
if [[ "$choice" =~ ^[0-9]+$ ]] && [[ "$choice" -ge 1 ]] && [[ "$choice" -le ${#AVAILABLE_VERSIONS[@]} ]]; then if [[ "$choice" =~ ^[0-9]+$ ]] && [[ "$choice" -ge 1 ]] && [[ "$choice" -le ${#AVAILABLE_VERSIONS[@]} ]]; then
PCT_OSVERSION="${AVAILABLE_VERSIONS[$((choice - 1))]}" PCT_OSVERSION="${AVAILABLE_VERSIONS[$((choice - 1))]}"
TEMPLATE=$(pveam available -section system 2>/dev/null | awk '{print $NF}' | grep "^${PCT_OSTYPE}-${PCT_OSVERSION}.*${TEMPLATE_PATTERN}" | sort -V | tail -1) TEMPLATE_SEARCH="${PCT_OSTYPE}-${PCT_OSVERSION}"
if [[ -n "$TEMPLATE" ]]; then SEARCH_PATTERN="^${TEMPLATE_SEARCH}-"
msg_ok "Selected: $TEMPLATE"
echo "[DEBUG] Retrying with version: $PCT_OSVERSION"
mapfile -t ONLINE_TEMPLATES < <(
pveam available -section system 2>/dev/null |
grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' |
awk -F'\t' '{print $1}' |
grep -E "${SEARCH_PATTERN}.*${TEMPLATE_PATTERN}" |
sort -t - -k 2 -V 2>/dev/null || true
)
if [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]]; then
TEMPLATE="${ONLINE_TEMPLATES[-1]}"
TEMPLATE_SOURCE="online" TEMPLATE_SOURCE="online"
echo "[DEBUG] Found alternative: $TEMPLATE"
else else
msg_error "No template found for ${PCT_OSTYPE} ${PCT_OSVERSION}" msg_error "No templates available for ${PCT_OSTYPE} ${PCT_OSVERSION}"
exit 225 exit 225
fi fi
else else
@ -3085,12 +3099,7 @@ create_lxc_container() {
exit 0 exit 0
fi fi
else else
msg_error "No templates available for ${PCT_OSTYPE}" msg_error "No ${PCT_OSTYPE} templates available at all"
echo ""
echo "Please check:"
echo " • Run: pveam update"
echo " • Check network connectivity"
echo " • Verify Proxmox VE version: pveversion"
exit 225 exit 225
fi fi
fi fi
@ -3148,9 +3157,9 @@ create_lxc_container() {
mapfile -t ONLINE_TEMPLATES < <( mapfile -t ONLINE_TEMPLATES < <(
pveam available -section system 2>/dev/null | pveam available -section system 2>/dev/null |
grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' | grep -E '\.(tar\.zst|tar\.xz|tar\.gz)$' |
awk '{print $NF}' | awk -F'\t' '{print $1}' |
grep -E "${SEARCH_PATTERN}.*${TEMPLATE_PATTERN}" | grep -E "${SEARCH_PATTERN}.*${TEMPLATE_PATTERN}" |
sort -V 2>/dev/null sort -t - -k 2 -V 2>/dev/null || true
) )
ONLINE_TEMPLATE="" ONLINE_TEMPLATE=""
[[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]] && ONLINE_TEMPLATE="${ONLINE_TEMPLATES[-1]}" [[ ${#ONLINE_TEMPLATES[@]} -gt 0 ]] && ONLINE_TEMPLATE="${ONLINE_TEMPLATES[-1]}"

View File

@ -29,7 +29,6 @@ get_cached_version() {
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
upgrade_package() { upgrade_package() {
local package="$1" local package="$1"
msg_info "Upgrading $package"
# Use same caching logic as ensure_dependencies # Use same caching logic as ensure_dependencies
local apt_cache_file="/var/cache/apt-update-timestamp" local apt_cache_file="/var/cache/apt-update-timestamp"
@ -46,7 +45,6 @@ upgrade_package() {
fi fi
$STD apt install --only-upgrade -y "$package" $STD apt install --only-upgrade -y "$package"
msg_ok "Upgraded $package"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -76,8 +74,6 @@ ensure_dependencies() {
done done
if [[ ${#missing[@]} -gt 0 ]]; then if [[ ${#missing[@]} -gt 0 ]]; then
msg_info "Installing dependencies: ${missing[*]}"
# Only run apt update if not done recently (within last 5 minutes) # Only run apt update if not done recently (within last 5 minutes)
local apt_cache_file="/var/cache/apt-update-timestamp" local apt_cache_file="/var/cache/apt-update-timestamp"
local current_time=$(date +%s) local current_time=$(date +%s)
@ -92,7 +88,6 @@ ensure_dependencies() {
cleanup_orphaned_sources 2>/dev/null || true cleanup_orphaned_sources 2>/dev/null || true
if ! $STD apt update; then if ! $STD apt update; then
msg_warn "apt update failed, attempting to fix..."
ensure_apt_working || return 1 ensure_apt_working || return 1
fi fi
echo "$current_time" >"$apt_cache_file" echo "$current_time" >"$apt_cache_file"
@ -102,7 +97,6 @@ ensure_dependencies() {
msg_error "Failed to install dependencies: ${missing[*]}" msg_error "Failed to install dependencies: ${missing[*]}"
return 1 return 1
} }
msg_ok "Installed dependencies"
fi fi
} }
@ -511,7 +505,6 @@ wait_for_apt() {
return 1 return 1
fi fi
debug_log "Waiting for apt to be available... (${waited}s)"
sleep 5 sleep 5
waited=$((waited + 5)) waited=$((waited + 5))
done done
@ -568,7 +561,6 @@ cleanup_orphaned_sources() {
# If keyring doesn't exist, remove the .sources file # If keyring doesn't exist, remove the .sources file
if [[ -n "$keyring_path" ]] && [[ ! -f "$keyring_path" ]]; then if [[ -n "$keyring_path" ]] && [[ ! -f "$keyring_path" ]]; then
msg_warn "Removing orphaned sources file: $basename_file (missing keyring: $(basename "$keyring_path"))"
rm -f "$sources_file" rm -f "$sources_file"
fi fi
done < <(find "$sources_dir" -name "*.sources" -print0 2>/dev/null) done < <(find "$sources_dir" -name "*.sources" -print0 2>/dev/null)
@ -589,8 +581,6 @@ ensure_apt_working() {
# Try to update package lists # Try to update package lists
if ! apt-get update -qq 2>/dev/null; then if ! apt-get update -qq 2>/dev/null; then
msg_warn "APT update failed, attempting to fix..."
# More aggressive cleanup # More aggressive cleanup
rm -f /etc/apt/sources.list.d/*.sources 2>/dev/null || true rm -f /etc/apt/sources.list.d/*.sources 2>/dev/null || true
cleanup_orphaned_sources cleanup_orphaned_sources
@ -616,8 +606,6 @@ setup_deb822_repo() {
local component="${5:-main}" local component="${5:-main}"
local architectures="${6:-amd64 arm64}" local architectures="${6:-amd64 arm64}"
msg_info "Setting up $name repository"
# Cleanup old configs for this app # Cleanup old configs for this app
cleanup_old_repo_files "$name" cleanup_old_repo_files "$name"
@ -654,8 +642,6 @@ EOF
$STD apt update $STD apt update
echo "$current_time" >"$apt_cache_file" echo "$current_time" >"$apt_cache_file"
fi fi
msg_ok "Set up $name repository"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -698,7 +684,7 @@ enable_and_start_service() {
local service="$1" local service="$1"
if ! systemctl enable "$service" &>/dev/null; then if ! systemctl enable "$service" &>/dev/null; then
msg_warn "Could not enable $service (may not be installed yet)" return 1
fi fi
if ! systemctl start "$service" &>/dev/null; then if ! systemctl start "$service" &>/dev/null; then
@ -793,7 +779,6 @@ end_timer() {
local label="${2:-Operation}" local label="${2:-Operation}"
local end_time=$(date +%s) local end_time=$(date +%s)
local duration=$((end_time - start_time)) local duration=$((end_time - start_time))
debug_log "$label took ${duration}s"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -912,27 +897,23 @@ check_for_gh_release() {
fi fi
if [[ "$current" != "$pin_clean" ]]; then if [[ "$current" != "$pin_clean" ]]; then
msg_info "${app} pinned to ${pinned_version_in} (installed ${current:-none}) → update required"
CHECK_UPDATE_RELEASE="$match_raw" CHECK_UPDATE_RELEASE="$match_raw"
msg_ok "Checking for update: ${app}"
return 0 return 0
fi fi
if [[ "$pin_clean" == "$latest_clean" ]]; then msg_ok "Checking for update: ${app}"
msg_ok "${app} pinned to ${pinned_version_in} (up to date)"
else
msg_ok "${app} pinned to ${pinned_version_in} (already installed, upstream ${latest_raw})"
fi
return 1 return 1
fi fi
# No pinning → use latest # No pinning → use latest
if [[ -z "$current" || "$current" != "$latest_clean" ]]; then if [[ -z "$current" || "$current" != "$latest_clean" ]]; then
CHECK_UPDATE_RELEASE="$latest_raw" CHECK_UPDATE_RELEASE="$latest_raw"
msg_info "New release available: ${latest_raw} (current: v${current:-none})" msg_ok "Checking for update: ${app}"
return 0 return 0
fi fi
msg_ok "${app} is up to date (${latest_raw})" msg_ok "Checking for update: ${app}"
return 1 return 1
} }
@ -1418,7 +1399,7 @@ function setup_adminer() {
CACHED_VERSION=$(get_cached_version "adminer") CACHED_VERSION=$(get_cached_version "adminer")
if grep -qi alpine /etc/os-release; then if grep -qi alpine /etc/os-release; then
msg_info "Installing Adminer (Alpine)" msg_info "Setup Adminer (Alpine)"
mkdir -p /var/www/localhost/htdocs/adminer mkdir -p /var/www/localhost/htdocs/adminer
curl -fsSL https://github.com/vrana/adminer/releases/latest/download/adminer.php \ curl -fsSL https://github.com/vrana/adminer/releases/latest/download/adminer.php \
-o /var/www/localhost/htdocs/adminer/index.php || { -o /var/www/localhost/htdocs/adminer/index.php || {
@ -1426,16 +1407,16 @@ function setup_adminer() {
return 1 return 1
} }
cache_installed_version "adminer" "latest-alpine" cache_installed_version "adminer" "latest-alpine"
msg_ok "Installed Adminer (Alpine)" msg_ok "Setup Adminer (Alpine)"
else else
msg_info "Installing Adminer (Debian/Ubuntu)" msg_info "Setup Adminer (Debian/Ubuntu)"
ensure_dependencies adminer ensure_dependencies adminer
$STD a2enconf adminer $STD a2enconf adminer
$STD systemctl reload apache2 $STD systemctl reload apache2
local VERSION local VERSION
VERSION=$(dpkg -s adminer 2>/dev/null | grep '^Version:' | awk '{print $2}') VERSION=$(dpkg -s adminer 2>/dev/null | grep '^Version:' | awk '{print $2}')
cache_installed_version "adminer" "${VERSION:-unknown}" cache_installed_version "adminer" "${VERSION:-unknown}"
msg_ok "Installed Adminer (Debian/Ubuntu)" msg_ok "Setup Adminer (Debian/Ubuntu)"
fi fi
} }
@ -1453,6 +1434,8 @@ function setup_composer() {
CACHED_VERSION=$(get_cached_version "composer") CACHED_VERSION=$(get_cached_version "composer")
export COMPOSER_ALLOW_SUPERUSER=1 export COMPOSER_ALLOW_SUPERUSER=1
msg_info "Setup Composer"
for old in /usr/bin/composer /bin/composer /root/.composer/vendor/bin/composer; do for old in /usr/bin/composer /bin/composer /root/.composer/vendor/bin/composer; do
[[ -e "$old" && "$old" != "$COMPOSER_BIN" ]] && rm -f "$old" [[ -e "$old" && "$old" != "$COMPOSER_BIN" ]] && rm -f "$old"
done done
@ -1460,14 +1443,6 @@ function setup_composer() {
ensure_usr_local_bin_persist ensure_usr_local_bin_persist
export PATH="/usr/local/bin:$PATH" export PATH="/usr/local/bin:$PATH"
if [[ -x "$COMPOSER_BIN" ]]; then
local CURRENT_VERSION
CURRENT_VERSION=$("$COMPOSER_BIN" --version 2>/dev/null | awk '{print $3}')
msg_info "Updating Composer from $CURRENT_VERSION to latest"
else
msg_info "Installing Composer"
fi
curl -fsSL https://getcomposer.org/installer -o /tmp/composer-setup.php || { curl -fsSL https://getcomposer.org/installer -o /tmp/composer-setup.php || {
msg_error "Failed to download Composer installer" msg_error "Failed to download Composer installer"
return 1 return 1
@ -1487,7 +1462,7 @@ function setup_composer() {
local FINAL_VERSION local FINAL_VERSION
FINAL_VERSION=$("$COMPOSER_BIN" --version 2>/dev/null | awk '{print $3}') FINAL_VERSION=$("$COMPOSER_BIN" --version 2>/dev/null | awk '{print $3}')
cache_installed_version "composer" "$FINAL_VERSION" cache_installed_version "composer" "$FINAL_VERSION"
msg_ok "Installed Composer $FINAL_VERSION" msg_ok "Setup Composer"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -1517,9 +1492,10 @@ function setup_ffmpeg() {
local CACHED_VERSION local CACHED_VERSION
CACHED_VERSION=$(get_cached_version "ffmpeg") CACHED_VERSION=$(get_cached_version "ffmpeg")
msg_info "Setup FFmpeg ${VERSION} ($TYPE)"
# Binary fallback mode # Binary fallback mode
if [[ "$TYPE" == "binary" ]]; then if [[ "$TYPE" == "binary" ]]; then
msg_info "Installing FFmpeg (static binary)"
curl -fsSL https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o "$TMP_DIR/ffmpeg.tar.xz" || { curl -fsSL https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz -o "$TMP_DIR/ffmpeg.tar.xz" || {
msg_error "Failed to download FFmpeg binary" msg_error "Failed to download FFmpeg binary"
rm -rf "$TMP_DIR" rm -rf "$TMP_DIR"
@ -1535,7 +1511,7 @@ function setup_ffmpeg() {
rm -rf "$TMP_DIR" rm -rf "$TMP_DIR"
cache_installed_version "ffmpeg" "$FINAL_VERSION" cache_installed_version "ffmpeg" "$FINAL_VERSION"
ensure_usr_local_bin_persist ensure_usr_local_bin_persist
msg_ok "Installed FFmpeg binary $FINAL_VERSION" msg_ok "Setup FFmpeg"
return 0 return 0
fi fi
@ -1555,8 +1531,6 @@ function setup_ffmpeg() {
return 1 return 1
fi fi
msg_info "Installing FFmpeg ${VERSION} ($TYPE)"
# Dependency selection # Dependency selection
local DEPS=(build-essential yasm nasm pkg-config) local DEPS=(build-essential yasm nasm pkg-config)
case "$TYPE" in case "$TYPE" in
@ -1649,7 +1623,7 @@ function setup_ffmpeg() {
rm -rf "$TMP_DIR" rm -rf "$TMP_DIR"
cache_installed_version "ffmpeg" "$FINAL_VERSION" cache_installed_version "ffmpeg" "$FINAL_VERSION"
ensure_usr_local_bin_persist ensure_usr_local_bin_persist
msg_ok "Installed FFmpeg $FINAL_VERSION" msg_ok "Setup FFmpeg"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -1698,13 +1672,12 @@ function setup_go() {
cache_installed_version "go" "$GO_VERSION" cache_installed_version "go" "$GO_VERSION"
return 0 return 0
else else
msg_info "Upgrading Go from $CURRENT_VERSION to $GO_VERSION"
rm -rf "$GO_INSTALL_DIR" rm -rf "$GO_INSTALL_DIR"
fi fi
else
msg_info "Installing Go $GO_VERSION"
fi fi
msg_info "Setup Go $GO_VERSION"
local TARBALL="go${GO_VERSION}.linux-${ARCH}.tar.gz" local TARBALL="go${GO_VERSION}.linux-${ARCH}.tar.gz"
local URL="https://go.dev/dl/${TARBALL}" local URL="https://go.dev/dl/${TARBALL}"
local TMP_TAR=$(mktemp) local TMP_TAR=$(mktemp)
@ -1722,7 +1695,7 @@ function setup_go() {
cache_installed_version "go" "$GO_VERSION" cache_installed_version "go" "$GO_VERSION"
ensure_usr_local_bin_persist ensure_usr_local_bin_persist
msg_ok "Installed Go $GO_VERSION" msg_ok "Setup Go $GO_VERSION"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -1764,7 +1737,7 @@ function setup_gs() {
return 0 return 0
fi fi
msg_info "Installing Ghostscript $LATEST_VERSION_DOTTED" msg_info "Setup Ghostscript $LATEST_VERSION_DOTTED"
curl -fsSL "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs${LATEST_VERSION}/ghostscript-${LATEST_VERSION_DOTTED}.tar.gz" -o "$TMP_DIR/ghostscript.tar.gz" || { curl -fsSL "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs${LATEST_VERSION}/ghostscript-${LATEST_VERSION_DOTTED}.tar.gz" -o "$TMP_DIR/ghostscript.tar.gz" || {
msg_error "Failed to download Ghostscript" msg_error "Failed to download Ghostscript"
@ -1800,7 +1773,7 @@ function setup_gs() {
rm -rf "$TMP_DIR" rm -rf "$TMP_DIR"
cache_installed_version "ghostscript" "$LATEST_VERSION_DOTTED" cache_installed_version "ghostscript" "$LATEST_VERSION_DOTTED"
ensure_usr_local_bin_persist ensure_usr_local_bin_persist
msg_ok "Installed Ghostscript $LATEST_VERSION_DOTTED" msg_ok "Setup Ghostscript $LATEST_VERSION_DOTTED"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -1815,7 +1788,7 @@ function setup_gs() {
# - Some things are fetched from intel repositories due to not being in debian repositories. # - Some things are fetched from intel repositories due to not being in debian repositories.
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
function setup_hwaccel() { function setup_hwaccel() {
msg_info "Setting Up Hardware Acceleration" msg_info "Setup Hardware Acceleration"
if ! command -v lspci &>/dev/null; then if ! command -v lspci &>/dev/null; then
$STD apt -y update $STD apt -y update
@ -1845,8 +1818,6 @@ function setup_hwaccel() {
case "$gpu_vendor" in case "$gpu_vendor" in
Intel) Intel)
msg_info "Detected Intel GPU — configuring Intel hardware acceleration"
if [[ "$os_id" == "ubuntu" ]]; then if [[ "$os_id" == "ubuntu" ]]; then
$STD apt -y install intel-opencl-icd || msg_error "Failed to install intel-opencl-icd" $STD apt -y install intel-opencl-icd || msg_error "Failed to install intel-opencl-icd"
else else
@ -1859,24 +1830,19 @@ function setup_hwaccel() {
$STD apt -y install va-driver-all ocl-icd-libopencl1 vainfo intel-gpu-tools || msg_error "Failed to install GPU dependencies" $STD apt -y install va-driver-all ocl-icd-libopencl1 vainfo intel-gpu-tools || msg_error "Failed to install GPU dependencies"
;; ;;
AMD) AMD)
msg_info "Detected AMD GPU — configuring Mesa-based hardware acceleration"
$STD apt -y install mesa-va-drivers mesa-vdpau-drivers mesa-opencl-icd vainfo clinfo || msg_error "Failed to install AMD GPU dependencies" $STD apt -y install mesa-va-drivers mesa-vdpau-drivers mesa-opencl-icd vainfo clinfo || msg_error "Failed to install AMD GPU dependencies"
# For AMD CPUs without discrete GPU (APUs) # For AMD CPUs without discrete GPU (APUs)
if [[ "$cpu_vendor" == "AuthenticAMD" && "$gpu_vendor" != "AMD" ]]; then if [[ "$cpu_vendor" == "AuthenticAMD" && "$gpu_vendor" != "AMD" ]]; then
msg_info "Detected AMD CPU (APU) — enabling VAAPI via Mesa"
$STD apt -y install libdrm-amdgpu1 firmware-amd-graphics || true $STD apt -y install libdrm-amdgpu1 firmware-amd-graphics || true
fi fi
;; ;;
NVIDIA) NVIDIA)
msg_info "Detected NVIDIA GPU — skipping automatic configuration (manual driver setup required)" # NVIDIA needs manual driver setup
msg_info "→ Please install proprietary drivers manually via: apt install nvidia-driver"
;; ;;
*) *)
# If no discrete GPU, but AMD CPU (e.g., Ryzen APU) # If no discrete GPU, but AMD CPU (e.g., Ryzen APU)
if [[ "$cpu_vendor" == "AuthenticAMD" ]]; then if [[ "$cpu_vendor" == "AuthenticAMD" ]]; then
msg_info "Detected AMD CPU without discrete GPU — installing Mesa OpenCL stack"
$STD apt -y install mesa-opencl-icd ocl-icd-libopencl1 clinfo || msg_error "Failed to install Mesa OpenCL stack" $STD apt -y install mesa-opencl-icd ocl-icd-libopencl1 clinfo || msg_error "Failed to install Mesa OpenCL stack"
else else
msg_error "No supported GPU vendor detected" msg_error "No supported GPU vendor detected"
@ -1893,7 +1859,7 @@ function setup_hwaccel() {
$STD adduser "$(id -u -n)" render $STD adduser "$(id -u -n)" render
fi fi
msg_ok "Hardware Acceleration Setup Complete" msg_ok "Setup Hardware Acceleration"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -1925,7 +1891,7 @@ function setup_imagemagick() {
return 0 return 0
fi fi
msg_info "Installing ImageMagick (Patience)" msg_info "Setup ImageMagick"
ensure_dependencies \ ensure_dependencies \
build-essential \ build-essential \
@ -1980,7 +1946,7 @@ function setup_imagemagick() {
rm -rf "$TMP_DIR" rm -rf "$TMP_DIR"
cache_installed_version "imagemagick" "$VERSION" cache_installed_version "imagemagick" "$VERSION"
ensure_usr_local_bin_persist ensure_usr_local_bin_persist
msg_ok "Installed ImageMagick $VERSION" msg_ok "Setup ImageMagick"
} }
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
@ -2034,23 +2000,19 @@ function setup_java() {
# Already at correct version, just upgrade if available # Already at correct version, just upgrade if available
upgrade_package "$DESIRED_PACKAGE" upgrade_package "$DESIRED_PACKAGE"
else else
msg_info "Upgrading Temurin JDK $JAVA_VERSION"
$STD apt update $STD apt update
$STD apt install --only-upgrade -y "$DESIRED_PACKAGE" $STD apt install --only-upgrade -y "$DESIRED_PACKAGE"
cache_installed_version "temurin-jdk" "$JAVA_VERSION" cache_installed_version "temurin-jdk" "$JAVA_VERSION"
msg_ok "Upgraded Temurin JDK $JAVA_VERSION"
fi fi
else else
msg_info "Setup Temurin JDK $JAVA_VERSION"
if [[ -n "$INSTALLED_VERSION" ]]; then if [[ -n "$INSTALLED_VERSION" ]]; then
msg_info "Removing old Temurin JDK $INSTALLED_VERSION"
$STD apt purge -y "temurin-${INSTALLED_VERSION}-jdk" $STD apt purge -y "temurin-${INSTALLED_VERSION}-jdk"
msg_ok "Removed old Temurin JDK"
fi fi
msg_info "Installing Temurin JDK $JAVA_VERSION"
$STD apt install -y "$DESIRED_PACKAGE" $STD apt install -y "$DESIRED_PACKAGE"
cache_installed_version "temurin-jdk" "$JAVA_VERSION" cache_installed_version "temurin-jdk" "$JAVA_VERSION"
msg_ok "Installed Temurin JDK $JAVA_VERSION" msg_ok "Setup Temurin JDK $JAVA_VERSION"
fi fi
} }