Driver Injection - Script Not Being Called
-
Server
- FOG Version: 1.3.5-RC-9
- OS: Ubuntu 14.04
Client
- Service Version:
- OS:
Description
Hi all,
I’ve got a driver injection scrip that should be called after the image has completed, though it doesn’t seem to be working at the moment. It’s definitely being called by the fog.postdownload script, but when I run list the directory of postdownloadscripts, I see that fog.postdrivers is white whereas the others are green. The script starts with #!/bin/sh… is there anything I’m missing?
-
The different color indicates that it doesn’t have the same permissions, specifically this one has less permissions than the others and likely isn’t allowed to be executed with the current permissions.
chmod 777 fog.postdrivers
Should fix the permissions.
That might not be all that’s wrong with it however, did you create this file on Windows?
-
@Quazz Ah, thanks! That’s fixed the issue
I’ll test it out whilst imaging a laptop and post back if I run into any further issues. And no, I didn’t create the script in Windows - I typed it out using vi on the Ubuntu box. -
@Quazz Unfortunately, it doesn’t seem to be working even after I’ve changed the permissions, which suggests the format of the script is wrong. I’m currently using this:
#!/bin/sh ceol='tput el'; machine='dmiedecode -s system-product-name'; #Gets machine model machine="${machine%"${machine##*[![:space:]]}"}" #Removes trailing space system64="/ntfs/Windows/SysWOW64/regedit.exe"; #Determine if it's 64 bit or not if [ =f "$system64" ]; then setarch="x64" else setarch="x86" fi dots "Preparing Drivers"; #Create the local folder on the imaged PC: mkdir /ntfs/Windows/DRV &>/dev/null; echo -n "In Progress"; # Only use CAB files for the drivers. # Place the cab files for the specific system on the FOG Server: # i.e. Model Latitude E5410, Windows 7 x64 image would be: # /fog/Drivers/Win7/Latitude E5410/x64 cabextract -d /ntfs/Windows/DRV "/images/Drivers/${machine}"/*.CAB &>/dev/null; # Add the driver location on the PC to devicepath in Registry: regfile="/ntfs/Windows/System32/config/SOFTWARE" key="\Microsoft\Windows\CurrentVersion\DevicePath" devpath="%SystemRoot%\inf;%SystemRoot%\DRV"; reged -e "$regfile" &>/dev/null <<EOFREG ed $key $devpath q y EOFREG # Remove the "In Progress" and replace it with: "Done" echo -e "\b\b\b\b\b\b\b\b\b\b\b${ceol}Done";
And this was admittedly taken from: https://forums.fogproject.org/topic/4278/utilizing-postscripts-rename-joindomain-drivers-snapins/3
-
@RobTitian16 This script seems to have quite a few problems.
#!/bin/bash ceol='tput el'; machine='dmiedecode -s system-product-name'; #Gets machine model machine="${machine%"${machine##*[![:space:]]}"}" #Removes trailing space system64="/ntfs/Windows/SysWOW64/regedit.exe"; #Determine if it's 64 bit or not if [ -f "$system64" ]; then setarch="x64" else setarch="x86" fi dots "Preparing Drivers"; #Create the local folder on the imaged PC: mkdir /ntfs/Windows/DRV &>/dev/null; echo -n "In Progress"; # Only use CAB files for the drivers. # Place the cab files for the specific system on the FOG Server: # i.e. Model Latitude E5410, Windows 7 x64 image would be: # /fog/Drivers/Win7/Latitude E5410/x64 cabextract -d /ntfs/Windows/DRV "/images/Drivers/${machine}"/*.CAB &>/dev/null; # Add the driver location on the PC to devicepath in Registry: regfile="/ntfs/Windows/System32/config/SOFTWARE" key="\Microsoft\Windows\CurrentVersion\DevicePath" devpath="%SystemRoot%\inf;%SystemRoot%\DRV"; reged -e "$regfile" &>/dev/null <<EOFREG ed $key $devpath q y EOFREG # Remove the "In Progress" and replace it with: "Done" echo -e "\b\b\b\b\b\b\b\b\b\b\b${ceol}Done";
Changed to use bash (as sh is more restrictive and does not support some of the things done here)
Changed =f if condition to the correct -f
setarch appears unused, however, so not even sure why that’s being checked for?
-
@Quazz Thanks very much!
I’ve just tried this through a debugging task, and I would expect it to at least make the directory C:\Windows\DRV, but it hasn’t for some reason. I couldn’t actually see it calling the script at all, even though it’s definitely being called in the fog.postdownload script. -
@RobTitian16 I don’t know what else you have in your scripts, I can only make guesses.
This script does not mount anything, so it wouldn’t be able to make the C:\Windows\DRV directory if the target is not mounted to begin with.
Of course if you have mounted it in another script (and not have it unmount it) then it should work, assuming everything works as expected.
-
@Quazz Thanks, that was my mistake (doh!)
I’ve since fixed it, though I suspect the dmidecode part isn’t working as it doesn’t extract the CAB file from the FOG server into the DRV folder on the Windows machine (I’m not altogether certain thatmachine='dmidecode -s system-product-name';
returns “Latitude E6410”).
The full script is below and doesn’t rely on anything else. In the meantime I’ll try it again and try running the dmidecode part in a debugging session to see if I can figure it out.EDIT: Doh! I had a typo… it’s dmidecode - NOT dmiedecode.
Unfortunately, the CAB extraction still doesn’t seem to be working#!/bin/bash . /usr/share/fog/lib/funcs.sh case $osid in 5|6|7|9) clear [[ ! -d /ntfs ]] && mkdir -p /ntfs getHardDisk if [[ -z $hd ]]; then handleError "Could not find hdd to use" fi getPartitions $hd for part in $parts; do umount /ntfs >/dev/null 2>&1 fsTypeSetting "$part" case $fstype in ntfs) dots "Testing partition $part" ntfs-3g -o force,rw $part /ntfs ntfsstatus="$?" if [[ ! $ntfsstatus -eq 0 ]]; then echo "Skipped" continue fi if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then echo "Not found" umount /ntfs >/dev/null 2>&1 continue fi echo "Success" break ;; *) echo " * Partition $part not NTFS filesystem" ;; esac done if [[ ! $ntfsstatus -eq 0 ]]; then echo "Failed" debugPause handleError "Failed to mount $part ($0)\n Args: $*" # Give the reader a chance to see what the error was sleep 12; # Terminate the post driver script exit 1; fi ceol='tput el'; machine='dmidecode -s system-product-name'; #Gets machine model machine="${machine%"${machine##*[![:space:]]}"}" #Removes trailing space dots "Preparing Drivers"; #Check if the DRV folder exists on the local PC: if [ ! -d "ntfs/Windows/DRV" ] then mkdir /ntfs/Windows/DRV &>/dev/null; echo -n "In progress" fi # Only use CAB files for the drivers. # Place the cab files for the specific system on the FOG Server: # i.e. Model Latitude E5410, Windows 7 x64 image would be: # /fog/Drivers/Win7/Latitude E5410/x64 cabextract -d /ntfs/Windows/DRV "/images/Drivers/${machine}"/*.CAB &>/dev/null; # Add the driver location on the PC to devicepath in Registry: regfile="/ntfs/Windows/System32/config/SOFTWARE" key="\Microsoft\Windows\CurrentVersion\DevicePath" devpath="%SystemRoot%\inf;%SystemRoot%\DRV"; reged -e "$regfile" &>/dev/null <<EOFREG ed $key $devpath q y EOFREG # Remove the "In Progress" and replace it with: "Done" echo -e "\b\b\b\b\b\b\b\b\b\b\b${ceol}Done"; esac
-
I do all the cab extractions before placing them in FOG. It copies the driver folders over, and it works. Of course your scripts look different than mine because I didn’t edit it that far from the original from the other post.
-
@adukes40 Thanks, that helps a lot! I’ve managed to get it working now doing exactly that
My one remaining question is… how do you get dots to appear on a new line? At the moment mine bunch up together, which isn’t very pretty at all# Script here to mount the drive... ceol=`tput el`; machine=`dmidecode -s system-product-name`; #Gets machine model machine="${machine%"${machine##*[![:space:]]}"}" #Removes trailing space system64="/ntfs/Windows/SysWOW64/regedit.exe"; #Determine if it's 64 bit or not dots "Creating driver folder on local system" # < This is fine on a new line. # Check if the DRV folder exists on the local PC. If not, create it: if [ ! -d "ntfs/Windows/DRV" ] then mkdir /ntfs/Windows/DRV &>/dev/null; echo -n "Done" fi # Check if the drivers exist on the FOG server. # If not, copy them across to the local PC (they must be extracted first on the FOG server): dots "Checking for Drivers on FOG Server" # < This bunches with the previous dots command. if [ -d "/images/Drivers/${machine}" ] then echo -n "Drivers found" dots "Copying Drivers to local system" # < This also bunches with the previous dots command. cp -r "/images/Drivers/${machine}/." "/ntfs/Windows/DRV" else echo -n "No drivers were found" # Give the reader a chance to see what the error was. sleep 10; # Terminate the post driver script. exit 1; fi # Add the driver location on the PC to devicepath in Registry: regfile="/ntfs/Windows/System32/config/SOFTWARE" key="\Microsoft\Windows\CurrentVersion\DevicePath" devpath="%SystemRoot%\inf;%SystemRoot%\DRV"; reged -e "$regfile" &>/dev/null <<EOFREG ed $key $devpath q y EOFREG # Remove the "In Progress" and replace it with: "Done" echo -e "\b\b\b\b\b\b\b\b\b\b\b\b\b\b\b${ceol}Done"; esac
-
@RobTitian16 just put a simple
echo "";
where you need a new line character -
@george1421 Or just a simple
echo
-
@Tom-Elliott @george1421
Ah, so simple! Thanks very much gents!