#!/bin/bash #Script version .2alpha #2014/11/2 #FOG version 1.2.0 #Copies drivers to a C:\drivers on a universal image based on the hardware #detected on PCI, USB & PNP. Full documentation & How-To's on the FOG Wiki. #http://www.fogproject.org/wiki/index.php/Auto_driver_Install #Andrew Single - Frontier School Division (Frontier loves FOG!) oIFS=$IFS; getDeviceName() { local devnamefull=`lspci -mm -d $1`; devnamefull=${devnamefull//\" \"/¤}; IFS=¤; pciDescr=($devnamefull); IFS=$oIFS; } #Read PCI Device strings pci=`lspci -n |cut -c 15-23`; usb=`lsusb |cut -c 23-32`; last=""; for device in $pci do #filter for unique devices if [ "$device" != "$last" ]; then last=$device; #Split up vendor & Device IDs dMfg=${device:0:4}; dDev=${device:5:4}; drvLoc="/images/drivers/$dMfg/$dDev"; #Does the driver folder exist? if [ -d $drvLoc ];then #Copy files getDeviceName $device; echo -n " * Copying ${pciDescr[4]} "; #Does the vendor folder exist? if [ -d /ntfs/Drivers/$dMfg ]; then cp -r $drvLoc /ntfs/Drivers/$dMfg else mkdir /ntfs/Drivers/$dMfg cp -r $drvLoc /ntfs/Drivers/$dMfg fi if [ -f $drvLoc/drvinstall.bat ]; then cat $drvLoc/drvinstall.bat >>/ntfs/Windows/Setup/Scripts/SetupComplete.cmd unix2dos /ntfs/Windows/Setup/Scripts/SetupComplete.cmd fi echo "Done."; fi fi done IFS=' '; #enumerate PNP devices pnpdevices=`dmesg |grep IDs`; for pnp in $pnpdevices do pnp=${pnp#*IDs }; pnp=${pnp:0:7}; #filter for unique devices if [ "$pnp" != "$last" ]; then last=$pnp; drvLoc="/images/drivers/pnp/$pnp"; #Does the driver folder exist? if [ -d $drvLoc ];then #Copy files echo -n " * Copying PnP Device $pnp ........"; #Does the folder exist? if [ -d /ntfs/Drivers/pnp ]; then cp -r $drvLoc /ntfs/Drivers/pnp else mkdir /ntfs/Drivers/pnp cp -r $drvLoc /ntfs/Drivers/pnp fi if [ -f $drvLoc/drvinstall.bat ]; then cat $drvLoc/drvinstall.bat >>/ntfs/Windows/Setup/Scripts/SetupComplete.cmd unix2dos /ntfs/Windows/Setup/Scripts/SetupComplete.cmd fi echo "Done."; fi #echo "No driver for $device."; fi done IFS=$oIFS; usb=`lsusb |cut -c 23-32`; for device in $usb do #filter for unique devices if [ "$device" != "$last" ]; then last=$device; #Split up vendor & Device IDs dMfg=${device:0:4}; dDev=${device:5:4}; drvLoc="/images/drivers/$dMfg/$dDev"; #Does the driver folder exist? if [ -d $drvLoc ];then #Copy files echo -n " * Copying USB Device Driver ........"; #Does the vendor folder exist? if [ -d /ntfs/Drivers/$dMfg ]; then cp -r $drvLoc /ntfs/Drivers/$dMfg else mkdir /ntfs/Drivers/$dMfg cp -r $drvLoc /ntfs/Drivers/$dMfg fi if [ -f $drvLoc/drvinstall.bat ]; then cat $drvLoc/drvinstall.bat >>/ntfs/Windows/Setup/Scripts/SetupComplete.cmd unix2dos /ntfs/Windows/Setup/Scripts/SetupComplete.cmd fi echo "Done."; fi #echo "No driver for $device."; fi done