From af688e88621a36eec93ac71aa0537391d72adda5 Mon Sep 17 00:00:00 2001 From: ghe0 Date: Fri, 8 Nov 2024 01:56:36 +0200 Subject: [PATCH] isolate code to scan kernel drivers --- create.sh | 6 +++--- creator_functions.sh | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/create.sh b/create.sh index 6249625..de7cc6d 100755 --- a/create.sh +++ b/create.sh @@ -19,14 +19,14 @@ echo_cyan "Installing scripts..." install_init_script echo_cyan "Installing kernel modules..." -install_module "$(df -T / | awk '{ print $2 }' | tail -1)" +# # Uncomment this section if you want to grab modules from the guest OS +# scan_modules +install_module virtio_net install_module btrfs install_module virtio_blk install_module msr install_module sev-guest install_module dm_crypt -disk_driver=$(lshw -c disk 2>/dev/null | grep -oE 'driver=[a-z\-\_]+' | cut -d '=' -f2) -[[ -n $disk_driver ]] && install_module "$disk_driver" echo_cyan "Building module dependency tree..." cp /lib/modules/${KERNEL}/modules.{order,builtin,builtin.modinfo} "${ROOT}/lib/modules/${KERNEL}/" diff --git a/creator_functions.sh b/creator_functions.sh index 247d5fc..32755b5 100644 --- a/creator_functions.sh +++ b/creator_functions.sh @@ -132,6 +132,19 @@ _install_module() { done <<< "$( echo "$depends" )" } +scan_modules() { + local drivers='' mod='' + install_module "$(df -T / | awk '{ print $2 }' | tail -1)" + + drivers=$(lshw -c disk 2>/dev/null | grep -oE 'driver=[a-z\_\-]+' | cut -d '=' -f2; + lshw -c network 2>/dev/null | grep -oE 'driver=[a-z\_\-]+' | cut -d '=' -f2) + + while read -r mod; do + [[ -z $mod ]] && continue + _install_module "$mod" + done <<< "$( echo "$drivers" )" +} + create_archive() { local archive="detee-$(hostnamectl hostname)-${KERNEL}.cpio.gz" echo_cyan "Creating archive $archive"