This commit is contained in:
MacRimi 2025-03-06 23:15:32 +01:00
parent 8e42d86ce6
commit 89828b731b

View File

@ -201,59 +201,107 @@ EOF
msg_error "$(translate "Failed to remove conflicting utilities")" msg_error "$(translate "Failed to remove conflicting utilities")"
fi fi
# update proxmox and install system utils # update proxmox and install system utils
msg_info "$(translate "Performing system upgrade...")" msg_info "$(translate "Performing packages upgrade...")"
apt-get install pv -y > /dev/null 2>&1 apt-get install pv -y > /dev/null 2>&1
total_packages=$(apt-get -s dist-upgrade | grep "^Inst" | wc -l) total_packages=$(apt-get -s dist-upgrade | grep "^Inst" | wc -l)
if [ "$total_packages" -eq 0 ]; then if [ "$total_packages" -eq 0 ]; then
total_packages=1 total_packages=1
fi fi
msg_ok "$(translate "Packages upgrade successfull")"
tput civis
tput sc
upgraded_packages=0
( (
/usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' dist-upgrade 2>&1 | \ /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' dist-upgrade 2>&1 | \
while IFS= read -r line; do while IFS= read -r line; do
if [[ "$line" =~ ^(Setting up|Unpacking|Preparing to unpack|Processing triggers for) ]]; then if [[ "$line" =~ ^(Setting up|Unpacking|Preparing to unpack|Processing triggers for) ]]; then
((upgraded_packages++))
progress=$((upgraded_packages * 100 / total_packages)) package_name=$(echo "$line" | sed -E 's/.*(Setting up|Unpacking|Preparing to unpack|Processing triggers for) ([^ ]+).*/\2/')
if [ "$progress" -gt 100 ]; then
progress=100
fi
printf "${TAB}\r\033[KProgress: [%-50s] %3d%%" "$(printf "#%.0s" $(seq 1 $((progress/2))))" "$progress"
[ -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"
sleep 0.2
done
fi fi
done done
) )
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
printf "\r%-$(($(tput cols)-1))s\r" " " tput rc
tput ed
msg_ok "$(translate "System upgrade completed")" msg_ok "$(translate "System upgrade completed")"
fi fi
# update PVE application manager
msg_info "$(translate "Updating PVE application manager, patience...")" msg_info "$(translate "Updating PVE application manager, patience...")"
total_steps=$(pveam update 2>&1 | grep -E "^(Downloading|Importing)" | wc -l) total_steps=$(pveam update 2>&1 | grep -E "^(Downloading|Importing)" | wc -l)
[ $total_steps -eq 0 ] && total_steps=1 [ $total_steps -eq 0 ] && total_steps=1
current_step=0
tput sc
( (
pveam update 2>&1 | while IFS= read -r line; do pveam update 2>&1 | while IFS= read -r line; do
if [[ $line == "Downloading"* ]] || [[ $line == "Importing"* ]]; then if [[ $line == "Downloading"* ]] || [[ $line == "Importing"* ]]; then
((current_step++))
progress=$((current_step * 100 / total_steps)) file_name=$(echo "$line" | sed -E 's/.* (Downloading|Importing) ([^ ]+).*/\2/')
printf "${TAB}\r$(translate "Progress"): [%-50s] %3d%%" $(printf "#%.0s" $(seq 1 $((progress/2)))) $progress
[ -z "$file_name" ] && file_name="$(translate "Unknown")"
tput rc
tput ed
row=$(( $(tput lines) - 6 ))
tput cup $row 0; echo "$(translate "Updating PVE application manager...")"
tput cup $((row + 1)) 0; echo "──────────────────────────────────────────────"
tput cup $((row + 2)) 0; echo "Downloading: $file_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"
sleep 0.2
done
fi fi
done done
) )
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
printf "\r%-$(($(tput cols)-1))s\r" " " tput rc
tput ed
msg_ok "$(translate "PVE application manager updated")" msg_ok "$(translate "PVE application manager updated")"
fi fi
tput cnorm
# Install additional Proxmox packages # Install additional Proxmox packages
msg_info "$(translate "Installing additional Proxmox packages...")" msg_info "$(translate "Installing additional Proxmox packages...")"
if /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' install zfsutils-linux proxmox-backup-restore-image chrony > /dev/null 2>&1; then if /usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' install zfsutils-linux proxmox-backup-restore-image chrony > /dev/null 2>&1; then
@ -580,44 +628,59 @@ configure_time_sync() {
install_system_utils() { install_system_utils() {
msg_info2 "$(translate "Installing common system utilities...")" msg_info2 "$(translate "Installing common system utilities...")"
# List of packages to install
packages=( packages=(
axel dialog dos2unix grc htop btop iftop iotop axel dialog dos2unix grc htop btop iftop iotop
iperf3 ipset iptraf-ng mlocate msr-tools net-tools omping iperf3 ipset iptraf-ng mlocate msr-tools net-tools omping
sshpass tmux unzip zip libguestfs-tools sshpass tmux unzip zip libguestfs-tools
) )
total_packages=${#packages[@]}
installed_packages=0
packages_to_install=() packages_to_install=()
# Check which packages need to be installed
for package in "${packages[@]}"; do for package in "${packages[@]}"; do
if ! dpkg -s "$package" >/dev/null 2>&1; then if ! dpkg -s "$package" >/dev/null 2>&1; then
packages_to_install+=("$package") packages_to_install+=("$package")
else
((installed_packages++))
fi fi
done done
if [ ${#packages_to_install[@]} -eq 0 ]; then if [ ${#packages_to_install[@]} -eq 0 ]; then
msg_ok "$(translate "System utilities installed successfully")" msg_ok "$(translate "System utilities installed successfully")"
else else
tput civis
tput sc
(
for package in "${packages_to_install[@]}"; do for package in "${packages_to_install[@]}"; do
/usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' install "$package" > /dev/null 2>&1
((installed_packages++))
progress=$((installed_packages * 100 / total_packages))
printf "${TAB}\r$(translate "Progress"): [%-50s] %3d%%" $(printf "#%.0s" $(seq 1 $((progress/2)))) $progress
done
)
if [ $? -eq 0 ]; then tput rc
printf "\r%-$(($(tput cols)-1))s\r" " " tput ed
row=$(( $(tput lines) - 6 ))
tput cup $row 0; echo "$(translate "Installing system utilities...")"
tput cup $((row + 1)) 0; echo "──────────────────────────────────────────────"
tput cup $((row + 2)) 0; echo "Package: $package"
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"
sleep 0.2
done
/usr/bin/env DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::='--force-confdef' install "$package" > /dev/null 2>&1
done
tput rc
tput ed
tput cnorm
msg_ok "$(translate "System utilities installed successfully")" msg_ok "$(translate "System utilities installed successfully")"
fi fi
fi
msg_success "$(translate "Common system utilities installation completed")" msg_success "$(translate "Common system utilities installation completed")"
} }