mirror of
https://github.com/MacRimi/ProxMenux.git
synced 2025-08-14 00:42:23 +00:00
Update customizable_post_install.sh
This commit is contained in:
parent
e76e303383
commit
f1b80d8f57
@ -182,223 +182,24 @@ EOF
|
||||
|
||||
|
||||
|
||||
|
||||
apt_upgrade() {
|
||||
msg_info2 "$(translate "Configuring Proxmox repositories")"
|
||||
NECESSARY_REBOOT=1
|
||||
local pve_version
|
||||
pve_version=$(pveversion 2>/dev/null | grep -oP 'pve-manager/\K[0-9]+' | head -1)
|
||||
|
||||
# Detect current Debian codename and Proxmox version
|
||||
local current_codename=$(lsb_release -cs 2>/dev/null || echo "bookworm")
|
||||
local pve_version=$(pveversion 2>/dev/null | grep -oP 'pve-manager/\K[0-9]+' | head -1)
|
||||
local is_pve9=false
|
||||
local target_codename="bookworm"
|
||||
if [[ -z "$pve_version" ]]; then
|
||||
msg_error "Unable to detect Proxmox version."
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Determine if we're dealing with PVE 9 or should upgrade to it
|
||||
if [ "$pve_version" -ge 9 ] 2>/dev/null || [ "$current_codename" = "trixie" ]; then
|
||||
is_pve9=true
|
||||
target_codename="trixie"
|
||||
msg_info2 "$(translate "Detected/Configuring for Proxmox VE 9.x - Using Debian Trixie")"
|
||||
if [[ "$pve_version" -ge 9 ]]; then
|
||||
|
||||
bash <(curl -fsSL "$REPO_URL/scripts/global/update-pve9.sh")
|
||||
else
|
||||
target_codename="$current_codename"
|
||||
msg_info2 "$(translate "Configuring for Proxmox VE 8.x - Using Debian $current_codename")"
|
||||
|
||||
bash <(curl -fsSL "$REPO_URL/scripts/global/update-pve8.sh")
|
||||
fi
|
||||
|
||||
# Disable enterprise proxmox repo (legacy format)
|
||||
if [ -f /etc/apt/sources.list.d/pve-enterprise.list ] && grep -q "^deb" /etc/apt/sources.list.d/pve-enterprise.list; then
|
||||
msg_info "$(translate "Disabling enterprise Proxmox repository...")"
|
||||
sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/pve-enterprise.list
|
||||
msg_ok "$(translate "Enterprise Proxmox repository disabled")"
|
||||
fi
|
||||
|
||||
# Disable enterprise Proxmox Ceph repo (legacy format)
|
||||
if [ -f /etc/apt/sources.list.d/ceph.list ] && grep -q "^deb" /etc/apt/sources.list.d/ceph.list; then
|
||||
msg_info "$(translate "Disabling enterprise Proxmox Ceph repository...")"
|
||||
sed -i "s/^deb/#deb/g" /etc/apt/sources.list.d/ceph.list
|
||||
msg_ok "$(translate "Enterprise Proxmox Ceph repository disabled")"
|
||||
fi
|
||||
|
||||
# Configure repositories based on target version
|
||||
if [ "$is_pve9" = true ]; then
|
||||
# Proxmox VE 9 - Use new deb822 format
|
||||
|
||||
# Remove old legacy repository files if they exist
|
||||
[ -f /etc/apt/sources.list.d/pve-public-repo.list ] && rm -f /etc/apt/sources.list.d/pve-public-repo.list
|
||||
[ -f /etc/apt/sources.list.d/pve-install-repo.list ] && rm -f /etc/apt/sources.list.d/pve-install-repo.list
|
||||
|
||||
# Create new deb822 format no-subscription repository
|
||||
msg_info "$(translate "Creating Proxmox VE 9 no-subscription repository...")"
|
||||
cat > /etc/apt/sources.list.d/proxmox.sources << 'EOF'
|
||||
Types: deb
|
||||
URIs: http://download.proxmox.com/debian/pve
|
||||
Suites: trixie
|
||||
Components: pve-no-subscription
|
||||
Signed-By: /usr/share/keyrings/proxmox-archive-keyring.gpg
|
||||
EOF
|
||||
msg_ok "$(translate "Proxmox VE 9 no-subscription repository created")"
|
||||
|
||||
else
|
||||
# Proxmox VE 8 - Use legacy format
|
||||
msg_info "$(translate "Configuring Proxmox VE 8 repositories...")"
|
||||
|
||||
# Enable free public proxmox repo (legacy format)
|
||||
if [ ! -f /etc/apt/sources.list.d/pve-public-repo.list ] || ! grep -q "pve-no-subscription" /etc/apt/sources.list.d/pve-public-repo.list; then
|
||||
echo "deb http://download.proxmox.com/debian/pve $target_codename pve-no-subscription" > /etc/apt/sources.list.d/pve-public-repo.list
|
||||
msg_ok "$(translate "Free public Proxmox repository enabled")"
|
||||
fi
|
||||
fi
|
||||
|
||||
# ======================================================
|
||||
# Configure main Debian repositories
|
||||
# ======================================================
|
||||
sources_file="/etc/apt/sources.list"
|
||||
|
||||
# Create backup of sources.list
|
||||
cp "$sources_file" "${sources_file}.backup.$(date +%Y%m%d_%H%M%S)"
|
||||
|
||||
# Replace Spanish mirror with main Debian mirror
|
||||
sed -i 's|ftp.es.debian.org|deb.debian.org|g' "$sources_file"
|
||||
|
||||
# If upgrading to PVE 9, update all bookworm references to trixie
|
||||
if [ "$is_pve9" = true ] && [ "$current_codename" != "trixie" ]; then
|
||||
msg_info "$(translate "Updating Debian repositories to Trixie...")"
|
||||
sed -i 's/bookworm/trixie/g' "$sources_file"
|
||||
# Also update any remaining codename references
|
||||
sed -i "s/$current_codename/trixie/g" "$sources_file"
|
||||
fi
|
||||
|
||||
# Clean and rebuild sources.list with proper repositories
|
||||
cat > "$sources_file" << EOF
|
||||
# Debian $target_codename repositories
|
||||
deb http://deb.debian.org/debian $target_codename main contrib non-free non-free-firmware
|
||||
deb http://deb.debian.org/debian $target_codename-updates main contrib non-free non-free-firmware
|
||||
deb http://security.debian.org/debian-security $target_codename-security main contrib non-free non-free-firmware
|
||||
EOF
|
||||
|
||||
msg_ok "$(translate "Debian repositories configured for $target_codename")"
|
||||
|
||||
# ===================================================
|
||||
# Disable non-free firmware warnings
|
||||
firmware_conf="/etc/apt/apt.conf.d/no-firmware-warnings.conf"
|
||||
if [ ! -f "$firmware_conf" ]; then
|
||||
msg_info "$(translate "Disabling non-free firmware warnings...")"
|
||||
echo 'APT::Get::Update::SourceListWarnings::NonFreeFirmware "false";' > "$firmware_conf"
|
||||
msg_ok "$(translate "Non-free firmware warnings disabled")"
|
||||
fi
|
||||
|
||||
# Update package lists with better error handling
|
||||
msg_info "$(translate "Updating package lists...")"
|
||||
|
||||
# First, try to update and capture any errors
|
||||
update_output=$(apt-get update 2>&1)
|
||||
update_exit_code=$?
|
||||
|
||||
if [ $update_exit_code -eq 0 ]; then
|
||||
msg_ok "$(translate "Package lists updated successfully")"
|
||||
else
|
||||
if echo "$update_output" | grep -q "NO_PUBKEY\|GPG error"; then
|
||||
msg_info "$(translate "Fixing GPG key issues...")"
|
||||
# Try to fix GPG key issues
|
||||
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys $(echo "$update_output" | grep "NO_PUBKEY" | sed 's/.*NO_PUBKEY //' | head -1) 2>/dev/null
|
||||
# Try update again
|
||||
if apt-get update > /dev/null 2>&1; then
|
||||
msg_ok "$(translate "Package lists updated after GPG fix")"
|
||||
else
|
||||
cleanup
|
||||
msg_error "$(translate "Failed to update package lists")"
|
||||
echo "Error details: $update_output"
|
||||
return 1
|
||||
fi
|
||||
elif echo "$update_output" | grep -q "404\|Failed to fetch"; then
|
||||
msg_warn "$(translate "Some repositories are not available, continuing with available ones...")"
|
||||
# Continue anyway as some repos might be temporarily unavailable
|
||||
else
|
||||
cleanup
|
||||
msg_error "$(translate "Failed to update package lists")"
|
||||
echo "Error details: $update_output"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Verify repositories are working correctly
|
||||
if [ "$is_pve9" = true ]; then
|
||||
msg_info "$(translate "Verifying Proxmox VE 9 repositories...")"
|
||||
if apt policy 2>/dev/null | grep -q "trixie.*pve-no-subscription"; then
|
||||
msg_ok "$(translate "Proxmox VE 9 repositories verified")"
|
||||
else
|
||||
msg_warn "$(translate "Proxmox VE 9 repositories verification inconclusive, continuing...")"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Remove conflicting utilities
|
||||
msg_info "$(translate "Removing conflicting utilities...")"
|
||||
if /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' purge ntp openntpd systemd-timesyncd > /dev/null 2>&1; then
|
||||
msg_ok "$(translate "Conflicting utilities removed")"
|
||||
else
|
||||
msg_warn "$(translate "Some conflicting utilities may not have been removed")"
|
||||
fi
|
||||
|
||||
# Update proxmox and install system utils
|
||||
msg_info "$(translate "Performing packages upgrade...")"
|
||||
apt-get install pv -y > /dev/null 2>&1
|
||||
|
||||
total_packages=$(apt-get -s dist-upgrade 2>/dev/null | grep "^Inst" | wc -l)
|
||||
if [ "$total_packages" -eq 0 ]; then
|
||||
total_packages=1
|
||||
fi
|
||||
|
||||
msg_ok "$(translate "Starting package upgrade process")"
|
||||
|
||||
tput civis
|
||||
tput sc
|
||||
|
||||
(/usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' dist-upgrade 2>&1 | \
|
||||
while IFS= read -r line; do
|
||||
if [[ "$line" =~ ^(Setting up|Unpacking|Preparing to unpack|Processing triggers for) ]]; then
|
||||
package_name=$(echo "$line" | sed -E 's/.*(Setting up|Unpacking|Preparing to unpack|Processing triggers for) ([^ ]+).*/\2/')
|
||||
[ -z "$package_name" ] && package_name="$(translate "Unknown")"
|
||||
|
||||
tput rc
|
||||
tput ed
|
||||
row=$(( $(tput lines) - 6 ))
|
||||
tput cup $row 0; echo "$(translate "Installing packages...")"
|
||||
tput cup $((row + 1)) 0; echo "──────────────────────────────────────────────"
|
||||
tput cup $((row + 2)) 0; echo "Package: $package_name"
|
||||
tput cup $((row + 3)) 0; echo "Progress: [ ] 0%"
|
||||
tput cup $((row + 4)) 0; echo "──────────────────────────────────────────────"
|
||||
|
||||
for i in $(seq 1 10); do
|
||||
progress=$((i * 10))
|
||||
tput cup $((row + 3)) 9
|
||||
printf "[%-50s] %3d%%" "$(printf "#%.0s" $(seq 1 $((progress/2))))" "$progress"
|
||||
done
|
||||
fi
|
||||
done)
|
||||
|
||||
upgrade_exit_code=$?
|
||||
tput rc
|
||||
tput ed
|
||||
|
||||
if [ $upgrade_exit_code -eq 0 ]; then
|
||||
msg_ok "$(translate "System upgrade completed successfully")"
|
||||
else
|
||||
msg_warn "$(translate "System upgrade completed with some issues")"
|
||||
fi
|
||||
|
||||
# Install additional Proxmox packages
|
||||
msg_info "$(translate "Installing additional Proxmox packages...")"
|
||||
local additional_packages="zfsutils-linux proxmox-backup-restore-image chrony"
|
||||
|
||||
if /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' install $additional_packages > /dev/null 2>&1; then
|
||||
msg_ok "$(translate "Additional Proxmox packages installed")"
|
||||
else
|
||||
msg_warn "$(translate "Some additional Proxmox packages may not have been installed")"
|
||||
fi
|
||||
|
||||
lvm_repair_check
|
||||
cleanup_duplicate_repos
|
||||
|
||||
if [ "$is_pve9" = true ]; then
|
||||
msg_ok "$(translate "Proxmox VE 9 configuration completed.")"
|
||||
fi
|
||||
|
||||
msg_success "$(translate "Proxmox repository configuration completed")"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user