Update pvekclean.sh v2.0.1

This commit is contained in:
Jordan
2023-11-13 02:19:39 +01:00
committed by GitHub
parent 6ce2bb2f3e
commit 6401ccd2ba
+5 -1
View File
@@ -315,7 +315,7 @@ uninstall_program() {
# PVE Kernel Clean main function # PVE Kernel Clean main function
pve_kernel_clean() { pve_kernel_clean() {
# Find all the PVE kernels on the system # Find all the PVE kernels on the system
kernels=$(dpkg --list | grep -E '(pve-kernel|proxmox-kernel)-.*-pve' | awk '{print $2}' | sed -n 's/\(pve\|proxmox\)-kernel-\(.*\)/\2/p' | sort -V) kernels=$(dpkg --list | grep -E '(pve-kernel|proxmox-kernel)-[0-9].*' | awk '{print $2}' | sed -n 's/\(pve\|proxmox\)-kernel-\(.*\)/\2/p' | sort -V)
# List of kernels that will be removed (adds them as the script goes on) # List of kernels that will be removed (adds them as the script goes on)
kernels_to_remove=() kernels_to_remove=()
# Check the /boot used # Check the /boot used
@@ -333,6 +333,10 @@ pve_kernel_clean() {
current_kernel_passed=false current_kernel_passed=false
for kernel in $kernels for kernel in $kernels
do do
# Check if the kernel is already in the array
if [[ " ${kernels_to_remove[@]} " =~ " $kernel " ]]; then
continue # Skip adding it again
fi
# Only if not removing newer kernels and kernel matches the current kernel # Only if not removing newer kernels and kernel matches the current kernel
if [ "$(echo $kernel | grep "$current_kernel")" ]; then if [ "$(echo $kernel | grep "$current_kernel")" ]; then
if [ "$remove_newer" == "false" ]; then if [ "$remove_newer" == "false" ]; then