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

Postdownload Script Cannot Find PostDrivers Script In Debug Mode?

Scheduled Pinned Locked Moved Solved
FOG Problems
3
6
1.3k
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.
  • R
    RobTitian16
    last edited by RobTitian16 Oct 25, 2017, 7:19 AM Oct 25, 2017, 1:18 PM

    Hi all,

    I have an issue with one of my scripts called fog.postclient which will create the directory “/ntfs/Windows/Setup/Scripts/” and then copy across the FogService.msi into it, as well as various other things (like moving the Sophos installer across, etc.). This has worked perfectly fine in the past with no issues whatsoever, and nothing has been changed in the script. Fog.Postdownload calls two scripts: fog.postclient, and fog.postdrivers. The drivers script works great.

    However, I’ve found recently that nothing in the fog.postclient works. Going by past experience and the recommendations here, I set a spare laptop to image as a debug task. When in debug mode, I call fog.postdownloads and it complains that it can’t see the postdrivers script. I get the error:

    ./fog.postdownload: line 7: .: fog.postdrivers: file not found
    

    Yet when running the fog.postclient script, it seems to work as it echoes ‘Non-Windows Deployment’ (which is a part of the script), but nothing else works - it doesn’t create the directory, or copy across the .msi file.

    The aforementioned scripts are below. I would appreciate any assistance/guidance on this issue.

    fog.postdownload:

    #!/bin/sh
    ## This file serves as a starting point to call your custom postimaging scripts.
    ## <SCRIPTNAME> should be changed to the script you're planning to use.
    ## Syntax of post download scripts are
    #. ${postdownpath}<SCRIPTNAME>
    
    . ${postdownpath}fog.postdrivers
    . ${postdownpath}fog.postclient
    

    fog.postclient:

    #!/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 install script 
                exit 1;
            fi
    
            # This next section determines the IP of the host system, cuts the last two octects and sets the FOGIP variable to
            # the correct IP address of the FOG server depending on the location (as the subnets are designed by location - i.e.
            # 10.1 is for the UK, 10.2 is for the US, etc.)   
    
            myip=$(ip route get 8.8.8.8 | awk 'NR==1 {print $NF}' | cut -d "." -f1-2)
    
            case "${myip}" in
    	        10.1)
    		        sitecode="UK";
    		        timezone="GMT Standard Time";
    		        FOGIP="10.1.0.102";
    			sitelocal="en-GB";
    			uilang="en-US";
    		        ;;
    	        10.2)
    		        sitecode="US";
    		        timezone="Eastern Standard Time";
    		        FOGIP="10.2.1.103";
    			sitelocal="en-US";
    			uilang="en-US";
    		        ;;
    	        *)
    		        # Default code for the unknowns - we set the FOGIP to the development server in the UK. 
    		        sitecode="CompanyName";
    		        timezone="Greenwich Mean Time";
    		        FOGIP="10.1.0.102";
    			sitelocal="en-GB";
    			uilang="en-GB";
    		        ;;
            esac
    	
    	# Check if the direcotry /ntfs/Windows/Setup/Scripts exists, and if not then create it.
    	if [ ! -d "ntfs/Windows/Setup/Scripts" ]
    	then	
    		mkdir /ntfs/Windows/Setup/Scripts
    	fi 
    
    	# Copy the FOGService.msi across to the target computer.
    	[[ -f ${postdownpath}FOGService.msi ]] && cp ${postdownpath}FOGService.msi "/ntfs/Windows/Setup/Scripts/FOGService.msi"
           
    	# Check if the file SophosInstaller.exe exists in the source folder and then copy it to the destination on
    	# the C: drive. 
    	if [ -f "/images/drivers/Common/SophosInstall.exe" ]; then
    		cp /images/drivers/Common/SophosInstall.exe /ntfs/Windows/Setup/SophosInstall.exe
    	fi
     
    	# Check if the file SetupComplete.cmd exists in the source folder and then copy it to the destination on 
            # the C: drive. 
    
            if [ -f "/images/drivers/Common/SetupComplete.cmd" ]; then
    	        cp /images/drivers/Common/SetupComplete.cmd /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
    			# append the msiexec command to the end of the setupComplete.cmd file 
    			echo "msiexec.exe /i %windir%\Setup\Scripts\FOGService.msi  /quiet USETRAY=\"0\" WEBADDRESS=\"${FOGIP}\" " >> /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
    			# Re-enable the FOGService
    			echo "sc config FOGService start= auto
    			del /Q /F c:\windows\system32\sysrep\unattend.xml
    			del /Q /F c:\windows\panther\unattend.xml
    			shutdown -t 0 -r" >> /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
    			# just in case we edited the setupcomplete.cmd file in unix lets filter it to make it DOS compatible
    			unix2dos /ntfs/Windows/Setup/Scripts/SetupComplete.cmd
            fi
    		
    		# now lets use the timezone variable and update the unattend.xml file. You may need to edit the variable to 
    		# point to where your unattend.xml file exists. Remember case IS important. 
    		unattendfile="/ntfs/Windows/Panther/unattend.xml";
    		sed -i -e "s#<TimeZone>\([^<][^<]*\)</TimeZone>#<TimeZone>$timezone</TimeZone>#gi" $unattendfile
    		
    		# now lets deal with the internationalization stuff in the unattend.xml file 
    		sed -i -e "s#<InputLocale>\([^<][^<]*\)</InputLocale>#<InputLocale>$sitelocal</InputLocale>#gi" $unattendfile
    		sed -i -e "s#<SystemLocale>\([^<][^<]*\)</SystemLocale>#<SystemLocale>$sitelocal</SystemLocale>#gi" $unattendfile
    		sed -i -e "s#<UILanguage>\([^<][^<]*\)</UILanguage>#<UILanguage>$uilang</UILanguage>#gi" $unattendfile
    		sed -i -e "s#<UserLocale>\([^<][^<]*\)</UserLocale>#<UserLocale>$sitelocal</UserLocale>#gi" $unattendfile
            ;;
        *)
            echo "Non-Windows Deployment"
            debugPause
            return
            ;;
    esac
    

    Edit: Also, before I get asked, the FOG version is the following:
    Running Version 1.5.0-RC-8
    SVN Revision: 6080

    W 1 Reply Last reply Oct 25, 2017, 5:14 PM Reply Quote 0
    • W
      Wayne Workman @RobTitian16
      last edited by Oct 25, 2017, 5:14 PM

      @robtitian16 Inside of fog.postdownload, add some debugging:

      #!/bin/sh
      ## This file serves as a starting point to call your custom postimaging scripts.
      ## <SCRIPTNAME> should be changed to the script you're planning to use.
      ## Syntax of post download scripts are
      #. ${postdownpath}<SCRIPTNAME>
      
      echo ""
      echo "postdownpath=${postdownpath}"
      echo "Directory listing for postdownpath:"
      ls -laht $postdownpath
      
      . ${postdownpath}fog.postdrivers
      . ${postdownpath}fog.postclient
      

      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!
      Daily Clean Installation Results:
      https://fogtesting.fogproject.us/
      FOG Reporting:
      https://fog-external-reporting-results.fogproject.us/

      1 Reply Last reply Reply Quote 1
      • george1421G
        george1421 Moderator
        last edited by Oct 25, 2017, 8:34 PM

        Can we also get an output of running this command on your FOG server?
        ls -la /images/postdownloadscripts

        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!

        1 Reply Last reply Reply Quote 0
        • george1421G
          george1421 Moderator
          last edited by george1421 Oct 25, 2017, 2:43 PM Oct 25, 2017, 8:42 PM

          IN addition to what Wayne posted I might change up the fog.postdownload and add in a few more comments and a debugPause command.

          #!/bin/sh
          ## This file serves as a starting point to call your custom postimaging scripts.
          ## <SCRIPTNAME> should be changed to the script you're planning to use.
          ## Syntax of post download scripts are
          #. ${postdownpath}<SCRIPTNAME>
          
          echo ""
          echo "postdownpath=${postdownpath}"
          echo "Directory listing for postdownpath:"
          ls -laht $postdownpath
          echo "Calling postdrivers";
          debugPause
          . ${postdownpath}fog.postdrivers
          echo "Calling postclient";
          debugPause
          . ${postdownpath}fog.postclient
          debugPause
          

          What the echo statements and the debugPause will do for you. When you run an image deploy and check the debug checkbox when you schedule the deploy. FOS will boot to the command line. Key in fog and FOS will single step through the deployment, pausing at each debugPause command. When you get to the echo statement echo "Calling postclient"; Hit ctrl-c and exit out to the command prompt. This will let you debug you postclient inside the FOS environment. You can manually call postclient and debug the script this way. When you are done with the debugging of the script you can key in fog and single step through the deployment again from the beginning without rebooting.

          When you have your script perfected remote all of the extra comments and the debugPause commands. The debugPause will not hurt to stay in since the script will only pause when its in debug mode and not normal mode.

          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!

          1 Reply Last reply Reply Quote 0
          • R
            RobTitian16
            last edited by Nov 3, 2017, 2:02 PM

            Thanks all - will hopefully get back to you next week with some of my findings (busy days…)

            1 Reply Last reply Reply Quote 0
            • R
              RobTitian16
              last edited by Nov 24, 2017, 1:32 PM

              It turns out this is working fine - we just didn’t have the correct folder on our FOG server for the model of laptop (which the script relies on). We’ve made some adjustments to the script and can confirm this now works.
              Thanks very much for the help!

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              • First post
                Last post

              210

              Online

              12.0k

              Users

              17.3k

              Topics

              155.2k

              Posts
              Copyright © 2012-2024 FOG Project