Post Download Scripts Included Variables
-
Hello, I am trying to create a post download script to add drivers to my image.
I have read many forum posts about this and have created my script. Most of those posts reference the$osid
variable that can be used in these scripts.I have different drivers for different versions of Windows 10 (1909, 2004, 20H2, …) but I don’t see a way of figuring out what version I am imaging on a computer.
So, I am thinking I could add the version number in the image name and add the logic to the script.
That being said, is there a variable for the image name?
I know that the images table in the database has andimageName
field, but is there a variable for it that can be used in the post download scripts?Also, is there a link/file where I can see what other variables are available to the FOS at that moment?
Thanks for the help!
-
@rodluz There is a couple of ways you can go about this. I’ll tell you the hacky way to get what variables you need.
Schedule a debug deploy. Schedule a deployment task to a test computer, before you hit the schedule task button tick the debug checkbox. Now pxe boot the target computer. After several screens of text you need to clear with the enter key you will be dropped to the FOS Linux command prompt. At the fos linux command prompt key in
fog
and press enter. This will start the imaging process in debug mode. The imaging process will stop at each breakpoint in the code. Contine the imaging process until the fog banner is displayed. Press ctrl-c to exit the script. Now key in the wordset
these are all of the variables available in the post install script. You can also run this command to see the parameters passed from the FOG server.cat /proc/cmdline
The image name you are looking for is defined there.Now to your task. You could use one of the tag fields in the host definition to pass a parameter to the post install script.
In my build environment I use MDT to create the golden image. One of the task sequences I have writes a build version to a text file. In the post install script I read that build version to identify if I need to do any fixup (swapping files, changing stuff in the golden image, etc) during a post install script. You could do something similar for the windows version. i.e. leave some bread crumbs behind in the golden image so you can use them during the post install script.
-
@george1421 I didn’t think of having a text file on the image itself, that is so simple to implement.
I’ll try both things out next week when I am back at the office.Thank you so much!
-
@rodluz Here is my code that I used top patch the deployed image. It has the concepts you might need.
#!/bin/bash # Only do patches of the PlatformVersion file exists if [ -f "/ntfs/Windows/PlatformVersion.rek" ] then platVersion=$(<"/ntfs/Windows/PlatformVersion.rek") echo " "; dots "Platform Version"; echo "${platVersion}"; # Identify what Image version we deployed case "${platVersion}" in 3.1.0.2*) # Unattend.xml is missing the driver load section rm -f /ntfs/Windows/Panther/*nattend.xml cp "/images/patches/${platVersion}/Unattend.xml" "/ntfs/Windows/Panther/Unattend.xml"; ;; 3.2.0.0*) # Unattend.xml is missing the driver load section cp "/images/patches/${platVersion}/Unattend.xml" "/ntfs/Windows/Panther/Unattend.xml"; ;; 3.3.0.2A*) # Unattend.xml is missing the driver load section echo "Patching the unattend file in 3.3.0.2A"; cp "/images/patches/3.3.0.2A/Unattend.xml" "/ntfs/Windows/Panther/Unattend.xml"; echo "Patching done"; ;; *) # Nothing really to do if the version is not identified echo "OS patching is not required"; echo " " ; ;; esac # Clean up any *nix stuff in the SetupComplete file [[ -f "/ntfs/Windows/Setup/Scripts/SetupComplete.cmd" ]] && unix2dos /ntfs/Windows/Setup/Scripts/SetupComplete.cmd debugPause; sleep 5; fi
-
@george1421 Thank you so much that helps a lot! I’ll have to modify a few things and test it out.
One question. What does the
dots
command do? I’ve tried to search what that command does in bash but I can’t find anything about it.EDIT: Also does the file have to be a
.rek
filetype or can it just be a txt? -
@rodluz said in Post Download Scripts Included Variables:
What does the dots command do?
That is a fog built in command. It makes pretty text like this.
This is step 1................ Cleaning up .................. Done Processing ..............
You will see this text during imaging. It fills the remainder of the line with dots adjusting based on the length of the text string.
Also does the file have to be a .rek filetype or can it just be a txt
I just picked a file extension probably not in use. The .rek file is short for I was a total brain wreck by the time I finally figured out how to do what I wanted to with that process.
-
@george1421 Ahh okay thank you!
-
@rodluz you can try this, https://forums.fogproject.org/topic/6463/expose-fog-host-and-image-properties-to-post-install-scripts?_=1620751811503 and make a review of host, image and hostinventory items…