Custom fog.man.reg issue
Im currently running version 1.5.7 of FOG and I was trying to get the Full Registration Host to auto populate the host name with a facility code + serial number. After following some guides, I was able to get the auto populated name working, but it seems like it’s now trying to send the newly registered name twice.
I think this (and I could be wrong, it could be something else) because it lets me do the whole registration process and at the end after it authenticates a FOG user, it throws the error along the line of “This host is already registered the system will reboot in 1 minutes”
However despite this error, after the 1 minute wait it will just continue on like normal and everything else works.
I used the serial grabbing code in this post by FredRick and just modified it slightly to include a prefix
I used this guide to figure out how to make the custom full registration menu
I had to deviate from step 2 in the 2nd link however as it didn’t seem to work for me (always says my new .fix file doesn’t exist and that theres is no debug command), so I just pointed at the fog.man.reg.fix directly in fog.postinit and it worked (at least as much as described) I also couldn’t for the life of me find the original /bin/fog.man.reg. I looked in both root and usr bin as well as the fog tree in /var/www/html and found nothing. I was wondering if maybe that why it’s triggering twice; perhaps it’s running the custom registration as well as the original?
Any help would be greatly appreciated!
@jazzbot I’m working on a solution/tutorial here: https://forums.fogproject.org/topic/14278/creating-custom-hostname-default-for-fog-man-reg
Nothing has been tested but in principal it should do what we need.
Thanks a ton george1421, that is a whole lot of very useful information. I actually can’t wait to play with it more to get it working the way I want. That load and go idea is an interesting option I think I’ll play around with too. (I love this hacky type of stuff personally )
Thank again, you’re a huge help!
You can get the 1.5.8 version of fog.man.reg from the github site. https://github.com/FOGProject/fos/blob/master/Buildroot/board/FOG/FOS/rootfs_overlay/bin/fog.man.reg
If you want to edit it and work on it using a windows computer use notepad++ instead of notepad. MS Notepad add extra windows bits to the file that will make linux cranky when you try to run it.
Ok so now to bring this full circle. I said in the beginning this feature has been a wish of mine since 2015 but I did nothing about it. I worked out a different process for naming that still follows the same naming convention. What we have/do is when we manually register a host computer we insert a usb bar code scanner into the rear usb port of the target computer. We have a laminated sheet with a barcode of the site LUM code, a D or L (D for desktop and L for laptop) in barcode form and then we scan the serial number tag Dell puts on its devices. That is how we low tech build the machine host names.
Now we also have what I call a Load and Go process where we will image a target computer but never manage it with FOG post install. In this case we pxe boot into the fog iPXE menu, pick deploy image and then select the target image. In the Load and Go mode, the post install script does all of the logic to determine the target computer’s name by querying SMBIOS,and then it calculates its host name and AD OU placement, then updates the unattend.xml file on the target computer. Since FOG forgets about this system once the imaging process is done there is nothing to update in FOG.
Well I can give you some guidance since this exact feature has been a request since I restart using fog in 2015. This feature was available in FOG version 0.3.x but disappeared some time after. With that said, I’ve made no attempt to reintroduce it to the FOG Project so that one is on me not the FOG developers.
With that said I can give you some guidance and some pointers if you want to make a custom fog.man.reg script.
First of all that script is in FOS Linux not the FOG server. FOS Linux is the operating system that is transferred to the target computer during pxe booting. FOS Linux consists of 2 files, the kernel (bzImage) and the virtual hard drive (init.xz) The files you seek are in the virtual hard drive (init.xz)
When FOS Linux starts up it contacts the FOG server just after booting and looks for a file called fog.postinit (or something like that, sorry too lazy to confirm) That fog.postinit script is intended to be used to bring up any specialty hardware needed before imaging can begin. In your case you will use that script to copy over your custom fog.man.reg to the FOS Linux disk before imaging will begin. We just named the patched version fog.man.reg.fix just so the name was unique on the FOG server. The patch file is copied from the fog server postinit directory to the /bin directory on the FOS Linux disk, basically overwriting what is there.
The script from your first link comes from my tutorial. In that we use dmidecode to read values (serial number in this case) out of the target computer’s SMBIOS.
You will see examples of what you can do with smbios in this tutorial. Also pay attention to how I can get a site specific LUM code based on the IP address of the target computer: https://forums.fogproject.org/topic/7740/the-magical-mystical-fog-post-download-script/15
Here is all of the bits in a cohesive and a bit more polished tutorial: https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed
In the case of the previous two links we are running this code in the Postinstall script section, this section is run after the image has been placed onto the target system hard drive. In this case a postinstall script would be to late to patch the fog.man.reg file, so the patching will be done on the postinit side.
When working on postinit or postinstall scripts its easiest to do in debug mode. To get into debug mode, when you schedule a capture or deploy you can tick the debug check box before you hit the submit button. Then when you pxe boot the target computer you will be dropped to a linux command prompt on the target computer. At the linux command prompt you key in
fogand press enter to start the imaging script. In the case of registration and not imaging, you can add a global kernel parameter
isdebug=1and that will place the manual registration mode into debug mode.