Zend certified PHP/Magento developer

I need help doing a bash shell script to index .inf files by hardware ID

I’m working on a new system to automate drivers installation in Windows 10/11. Some time ago, I downloaded a drivers collection from driverpack (the drivers collection is fine, but the software to manage the installations, I think may have viruses…) So I can install pretty much any Windows driver but it lasts a long time. I have the drivers collection in a SAMBA share in my server (FREEBNT from now on. It is Ubuntu 22.04.1). So when I want to install any drivers it has to search for the correct .inf file in the collection, and it can be like 20 minutes or more.
Then I have recently come up with the idea of doing a drivers database (MySQL) with hardware IDs and file paths (for the .inf files), and doing a PowerShell script to automate the installation of drivers using the database and downloading the drivers through SAMBA.
I asked the ChatGPT to do the code for me, and it has helped me a lot, but there are some errors in its proposed solution.
The project is comprised of 2 main parts:

  1. generating a MySQL database with a table which in turn has two columns: hwid and path, containing entries for every .inf file and its hardware IDs.
  2. generating the different necessaries powershell scripts to install the drivers using the previous database.

Right now I’m in the first step – generating the database. But the script provided by ChatGPT is not perfect. here is the script.
Note: FREEBNT is a server which has lots of storage. It acts as SAMBA server and other functions as well, but for this matter, the important thing is that it acts as the MySQL server and SAMBA server as well, and also it will run the bash shell script which will generate the MySQL database including all the .inf files and their Hardware IDs.
Here is the script.

#!/bin/bash

# Set up MySQL database connection parameters
db_user="mymysqluser"
db_pass="mymysqlpass"
db_name="drivers"
db_host="127.0.0.1"

# Set up the path to your drivers collection
drivers_path="/free/fr/drivers/"

# Loop through all INF files in the drivers collection
for inf_file in $(find "$drivers_path" -type f -name "*.inf"); do

  # Extract hardware IDs from INF file
  hwids=$(grep -iE "^driverver|^pci|usb\\" "$inf_file" | awk -F ",|=" '{print $2}' | tr -d ' ' | sort -u)
  
  #convert the inf file path to a path readable by Windows systems through SAMBA (added by borhacker)
  inf_file2=$(echo $inf_file | sed 's//free/fr/drivers//\2.168.1.2\Fr-drivers\/')
  inf_file3=$(echo $inf_file2 | sed 's///\/g')

  # Loop through all hardware IDs and insert them into the database
  for hwid in $hwids; do
    echo "Inserting $hwid for $inf_file3 into database..."
    mysql -u $db_user -p$db_pass -h $db_host $db_name -e "INSERT INTO drivers (hwid, path) VALUES ('$hwid', '$inf_file3');"
  done

done

The section labeled as ‘added by borhacker‘ is made by me, because the file paths are not the same from FREEBNT or from Windows 10 accessing the SAMBA share. So when the variable inf_file contains, for example:

/free/fr/drivers/bluetooth/DP_Bluetooth_22094/MediaTek/FORCED/10x64/7921_1.3.14.133_tequila/mtkbtfilter.inf

the variable inf_file3 contains:

2.168.1.2Fr-driversbluetoothDP_Bluetooth_22094MediaTekFORCED10x647921_1.3.14.133_tequilamtkbtfilter.inf

The rest of the script, I understand everything(not everyting!). I have studied it to understand its behavior. The only thing I don’t understand is this part:

  # Extract hardware IDs from INF file
  hwids=$(grep -iE "^driverver|^pci|usb\\" "$inf_file" | awk -F ",|=" '{print $2}' | tr -d ' ' | sort -u)

And I guess the problem is there. I understand that this, supposedly, extracts the Hardware IDs from each .inf file. But when I’m running the script it is not extracting the Hardware IDs. And this is why I have studied the script. It extracts, generally, dates, like, for example (output of running the script for some time):

root@freebnt:/home/borhacker# ./indexdrivers-edit.sh
Inserting 07/10/2016 for 2.168.1.2Fr-driversvideoDP_Video_nVIDIA-XP_22080nVidiaFORCED5x86368.81nvmmi.inf into database...
mysql: [Warning] Using a password on the command line interface can be insecure.
Inserting 07/10/2016 for 2.168.1.2Fr-driversvideoDP_Video_nVIDIA-XP_22080nVidiaFORCED5x86368.81nvbli.inf into database...
mysql: [Warning] Using a password on the command line interface can be insecure.
Inserting 07/10/2016 for 2.168.1.2Fr-driversvideoDP_Video_nVIDIA-XP_22080nVidiaFORCED5x86368.81nvlei.inf into database...
mysql: [Warning] Using a password on the command line interface can be insecure.
Inserting 07/10/2016 for 2.168.1.2Fr-driversvideoDP_Video_nVIDIA-XP_22080nVidiaFORCED5x86368.81nvami.inf into database...
mysql: [Warning] Using a password on the command line interface can be insecure.


Now, I’d like if someone could point me in the right direction to create the correct script which would generate the MySQL database. I don’t know very well this Linux tools to process text and neither the content of Windows’ inf. files.
Thanks in advance.