• Register
    • Login
    • Search
    • Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    Unsolved Driver Injection - Script Not Being Called

    FOG Problems
    5
    13
    2584
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • RobTitian16
      RobTitian16 last edited by RobTitian16

      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?

      1 Reply Last reply Reply Quote 0
      • RobTitian16
        RobTitian16 @Tom Elliott last edited by

        @Tom-Elliott @george1421
        Ah, so simple! Thanks very much gents!

        1 Reply Last reply Reply Quote 0
        • Tom Elliott
          Tom Elliott @george1421 last edited by

          @george1421 Or just a simple echo

          Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG! Get in contact with me (chat bubble in the top right corner) if you want to join in.

          Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

          Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

          RobTitian16 1 Reply Last reply Reply Quote 3
          • george1421
            george1421 Moderator @RobTitian16 last edited by

            @RobTitian16 just put a simple echo ""; where you need a new line character

            Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

            Tom Elliott 1 Reply Last reply Reply Quote 2
            • RobTitian16
              RobTitian16 @adukes40 last edited by

              @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 
              
              
              george1421 1 Reply Last reply Reply Quote 0
              • adukes40
                adukes40 last edited by

                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.

                RobTitian16 1 Reply Last reply Reply Quote 1
                • RobTitian16
                  RobTitian16 @Quazz last edited by RobTitian16

                  @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 that machine='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 
                  
                  
                  1 Reply Last reply Reply Quote 0
                  • Q
                    Quazz Moderator @RobTitian16 last edited by

                    @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.

                    RobTitian16 1 Reply Last reply Reply Quote 2
                    • RobTitian16
                      RobTitian16 @Quazz last edited by

                      @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.

                      Q 1 Reply Last reply Reply Quote 0
                      • Q
                        Quazz Moderator @RobTitian16 last edited by Quazz

                        @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?

                        RobTitian16 1 Reply Last reply Reply Quote 2
                        • RobTitian16
                          RobTitian16 @Quazz last edited by RobTitian16

                          @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

                          Q 1 Reply Last reply Reply Quote 0
                          • RobTitian16
                            RobTitian16 @Quazz last edited by

                            @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.

                            1 Reply Last reply Reply Quote 0
                            • Q
                              Quazz Moderator last edited by

                              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?

                              RobTitian16 2 Replies Last reply Reply Quote 1
                              • 1 / 1
                              • First post
                                Last post

                              80
                              Online

                              10.4k
                              Users

                              16.4k
                              Topics

                              150.5k
                              Posts

                              Copyright © 2012-2023 FOG Project