From 6433d80b259d5e94cbac29338d4a3398ca065249 Mon Sep 17 00:00:00 2001 From: oasido Date: Sat, 28 Sep 2024 11:05:28 +0300 Subject: [PATCH] update through script - 2024-09-28 11:05:28 --- .local/bin/scripts/dkms-clean | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 .local/bin/scripts/dkms-clean diff --git a/.local/bin/scripts/dkms-clean b/.local/bin/scripts/dkms-clean new file mode 100755 index 0000000..f90fbc8 --- /dev/null +++ b/.local/bin/scripts/dkms-clean @@ -0,0 +1,22 @@ +#!/bin/bash +# 2024-09-28 11:02 +# github.com/oasido + +current_kernel=$(uname -r) + +dkms_modules=$(sudo dkms status) + +echo "$dkms_modules" | while read -r line; do + module_name=$(echo "$line" | cut -d',' -f1) + module_version=$(echo "$line" | cut -d',' -f2 | tr -d ' ') + + kernel_version=$(echo "$line" | cut -d',' -f2 | tr -d ' ') + + if [ "$kernel_version" != "$current_kernel" ]; then + echo "Removing $module_name $module_version for kernel $kernel_version" + sudo dkms remove "$module_name/$module_version" -k "$kernel_version" + else + echo "Keeping $module_name $module_version for current kernel $current_kernel" + fi +done +