Deploy image right after registration without a reboot
-
Hi
I have been using FOG using a USB to boot and do the registration for some time now.
I previously modified the fog.man.reg file to go directly to the fog.download before reboot to trigger the deployment.
I would do this buy inserting the following at the end of the fog.man.reg file
sysuuid=$(dmidecode -s system-uuid) sysuuid=${sysuuid,,}switch mac=$(getMACAddresses) curl -Lks -o /tmp/hinfo.txt --data "sysuuid=${sysuuid}&mac=$mac" "${web}service/hostinfo.php" -A '' [[ -f /tmp/hinfo.txt ]] && . /tmp/hinfo.txt . /bin/fog.download
Now I have updated to the latest Kernel (6.6.44) and Initrd file (2024.02.4) and it does not seem to work anymore.
This is the error I get.
But if I reboot and boot back into the system it deploys no problem.
Is there something I am doing wrong ?
-
@zaboxmaster This should work unless something changed in the inits.
So first lets start a debug deployment. Tick the debug checkbox before you schedule the deployment. pxe boot the target computer. After a few screens of text that you need to clear by pressing the enter key you will be dropped at a the fos linux command prompt (I understand that you usb boot but we need to pxe boot here to get into the right mode).
(insert flash back) you updated the fog.man.reg file and its copied over to the FOS image using the fog postinit script file. Its possible that the custom fog.man.reg file is not being delivered to fos linux.
So what you will do is single step through the deployment until we get to the postinit section.
(back to reality) at the fos linux command prompt key in
fog
At each breakpoint in the deployment you will need to press the enter key. Somewhere along the way before the partclone screen you will see the message about the postinit scripts running. Press the ctrl-c after the post init scripts run. Now verify that the fog.man.reg file in /bin on the fos linux engine has been updated with the curl command from your OP.If that file has been updated. then try to execute the curl command from your OP. That should create a file in /tmp as hinfo.txt look to see if it has content. It should have many lines of variables with its value.
-
@george1421 we added a little security bit now too as getting the hostinfo gave us the host sensitive information (ad user , domain , password, etccc.)
https://github.com/FOGProject/fos/blob/master/Buildroot/board/FOG/FOS/rootfs_overlay/bin/fog#L9
This is the main difference.
We now need to get a token, and pass that token back to the hostinfo (it’s one time and locks upon initial request.)
Edit: Apologies on not posting the direct example, this was written while from my phone, not at a computer so copy paste wasn’t really “suitable”.
-
@Tom-Elliott Thank you for the update. I should have looked at the code.
So the OP needs to update the current curl call with this ?
base64mac=$(echo $mac | base64) token=$(curl -Lks --data "mac=$base64mac" "${web}status/hostgetkey.php") curl -Lks -o /tmp/hinfo.txt --data "sysuuid=${sysuuid}&mac=$mac&hosttoken=${token}" "${web}service/hostinfo.php" -A ''
To make it work now?
-
@george1421 I suspect so yes.
-
Thank you so much. I will try this out and let you know.
-
@zaboxmaster @george1421 @Tom-Elliott I have a possible solution for this issue that I just figured out today, I’ve been working on a similar situation but instead of using fog.man.reg Im using quick reg. So what I did to achieve this is I used the post init script to inject a modified version of fog.auto.reg into FOS that includes a section to call capone after the registration, I used information from this post and a past post https://forums.fogproject.org/topic/14278/creating-custom-hostname-default-for-fog-man-reg
to accomplish what I wanted to do on that partwhen adding this at first I got an invalid parameter for the dmi value error similiar to your osid error youre getting but when checking in the capone pxe menu I saw how it list mode=capone shutdown=0 and dmi=system-manufacturer so for giggles I added after mode=autoreg i included dmi=system-manufacturer and it went through like a charm.
So in the web interface go to the pxe menu settings and under fog.reginput try putting osid=9 beside it if your image is a windows image or the appropriate id based off the OS you’re using. Hopefully it will achieve the same thing for you as it did for me. -
The purpose of me using Capone for me is because we use all hps so I already have Capone configured to serve the golden image based off of the system-manufacturer matching HP
-