fog.postdownload not running
-
I am running FOG 1.5.2. From what I have read, if I want to run post install tasks, I can created a script, and call that script from /images/postdownloadscripts/fog.postdownload. I have tried adding a very simple script that just creates a file to test it, but the file is not created. I also tried just adding the “touch” command directly to the fog.postdownload file, and that also didn’t seem to do anything.
Is there anything that I need to do to enable the fog.postdownload file to be called, or it always is called by default? Anyway to debug this?
I do not see anywhere in the FOG GUI to edit the fog.postdownload file or ensure that it is enabled?
[root@raspschpxe1001 ~]# cat /images/postdownloadscripts/fog.postdownload #!/bin/bash ## 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.postTest [root@raspschpxe1001 ~]# cat /images/postdownloadscripts/fog.postTest #!/bin/bash . /usr/share/fog/lib/funcs.sh touch ~/testfile
-
@JRyanCon said in fog.postdownload not running:
Is the fog.postdownload only run if you push a FOG image to the target? I am not using images at the moment.
Ugh, yes that is only for actually deploying with FOG. You are using fog to pxe boot into installation media. This isn’t the intent of FOG imaging. Once you have your golden linux image you can capture and deploy with FOG then have access to the post down scripts. This what we did for the physical machines we created a golden linux image then capture and deploy with fog. The fog post install scripts update a few config files on the target computer and then exits. When the target computer boots it has its basic settings. With VMs its easier to deploy from a template than use FOG.
-
@JRyanCon Well you need to understand the postinstall script runs from/on the FOS engine (the customized linux that runs on the target computer). So when you reference /tmp or in your case ~/testfile, that file is created on FOS which executes only from memory. So when FOS exits the virtual hard drive is disposed of as well as your test file.
What you really want to do is create a test file on the target computer so you can be sure the script runs. If you look at this tutorial:
https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-edSpecifically the fog.custominstall script. You will see that this script connects FOS to the target computer’s windows partition using the linux mount command. Within FOS the windows partition is mounted on a directory called /ntfs. So if you wanted to write a test file to the drive you would mount the drive partition and then
touch /ntfs/testfile
You would place that touch command inside this section of the script.
echo "Done" debugPause #. ${postdownpath}fog.copydrivers # >> insert the touch command here << # . ${postdownpath}fog.updateunattend umount /ntfs ;;
-
@george1421 I read the link you provided and have a few questions:
-
It looks like there are some functions being called like getHardDisk and debugPause. Are these functions from . /usr/share/fog/lib/funcs.sh?
-
Where can i see all the functions available in funcs.sh?
-
When I do a echo called from a file called from fog.postdownload, it does not print to the screen. How do I see the output?
-
-
@JRyanCon said in fog.postdownload not running:
It looks like there are some functions being called like getHardDisk and debugPause. Are these functions from . /usr/share/fog/lib/funcs.sh?
Yes those are FOG core functions.
Where can i see all the functions available in funcs.sh?
If you start boot into FOS (schedule a capture/deploy but select the debug option before scheduling the task. The funcs.sh script is in /usr/share/fog/lib
When I do a echo called from a file called from fog.postdownload, it does not print to the screen. How do I see the output?
It should echo when the post install script is running. To debug your postinstall script if you boot FOS into debug mode (capture or deploy) you can single step through a deployment or capture by keying in
fog
as the FOS linux command prompt. When I was debugging postinstall scripts, I put quite a bit of echo statements in so I knew exactly where the script was at. If you include debugPause commands the script will stop there and wait for a keypress. You can abort the task on FOS by keying in Crtl-C. Fix your script and then restart the capture/deployment by keying in againfog
at the FOS command prompt. -
@george1421 I do not see any print statements to the screen.
I thought I would try the debug mode, so I added it to the FOG iPXE menu and booted to it. When I do, I get prompted to enter a UN/PW. I tried the FOG admin UN/PW, and seems like it didnt take it. It asks again for the UN/PW then just seems to boot to one of the iPXE options, with no difference in the behavior.
I tried looking around for how to create a debug mode account, but only found this page, which looks far out of date.
https://wiki.fogproject.org/wiki/index.php/Debug_Mode_is_asking_me_for_a_password -
@JRyanCon said in fog.postdownload not running:
I tried looking around for how to create a debug mode account, but only found this page, which looks far out of date
If you schedule a task, but before you hit the schedule task button, tick the check box for debug mode, then pxe boot the target computer. That’s it nothing to create. There is no password for root, you will be logged in directly to the linux command prompt as root.
Now if you want to remote debug, once FOS is at the linux command prompt, get the IP address of FOS with
ip addr show
to get the ip address of eth0. And then set root’s password withpasswd
give it a simple password likehello
. Once you have that set you can remotely connect to FOS via putty (ssh) and remote debug your scripts. Its easier to copy and paste using putty than the built in vi editor on the FOS console. -
@JRyanCon if you are not seeing the echo commands, then maybe your postinstall script isn’t running. Did you update the FOG’s default fog.postdownload script to call your custom script. As in the
fog.postdownload
section in the tutorial I linked before.. ${postdownpath}/fog.custominstall
I would put an echo in the fog.postdownload script and then one at the head of fog.custominstall script so you know when/if your script gets called.
-
@george1421 Yes, I included the call to the script in the fog.postdownload script. I also tried putting the echo into the fog.downloadscript directly. I also do not see any echo to the screen after the install completes. It doesnt seem like the fog.downloadscript is called/running.
[root@raspschpxe1001 postdownloadscripts]# cat /images/postdownloadscripts/fog.postdownload #!/bin/bash ## 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.postTest . /usr/share/fog/lib/funcs.sh echo "TESTING START" debugPause
-
@JRyanCon Hmmm this is interesting. The postdownload script should run just after the image has been pushed to the target computer. I know it works because I’m using it to push the drivers to the target computers.
-
@george1421 Is the fog.postdownload only run if you push a FOG image to the target? I am not using images at the moment. The client is pointing to an unpacked iso and letting the user manually walk through the install, or using a kickstart to automate the install.
Note that, I know that i could use the %POST section of the kickstart, but we plan to also use Linux images, as well as Windows images, attended and unattended installs. I wanted to try this for.postdownload capability thinking it might give me a common process no matter the type of install done.
:OS.RHEL.75 :RHEL75NetInstall set base <IP_ADRESS>/iso/PXE/RHEL/75 kernel ${base}/images/pxeboot/vmlinuz initrd=initrd.img repo=${base} initrd ${base}/images/pxeboot/initrd.img boot
-
@JRyanCon said in fog.postdownload not running:
Is the fog.postdownload only run if you push a FOG image to the target? I am not using images at the moment.
Ugh, yes that is only for actually deploying with FOG. You are using fog to pxe boot into installation media. This isn’t the intent of FOG imaging. Once you have your golden linux image you can capture and deploy with FOG then have access to the post down scripts. This what we did for the physical machines we created a golden linux image then capture and deploy with fog. The fog post install scripts update a few config files on the target computer and then exits. When the target computer boots it has its basic settings. With VMs its easier to deploy from a template than use FOG.
-
@george1421 Thanks, that is helpful to know.