Post Init Script Issues
-
I have FOG Server 1.5.9 and I was trying to customize my FOG reg menu.
I followed this post: https://forums.fogproject.org/topic/9754/custom-full-host-registration-for-1-3-4 as I wanted to change a few things in my script, namely change the “other user tag #1” and “other user tag #2” to be different questions. I have updated that and created the “patch.fullreg” file in /images/dev/postinitscripts and the fog.man.reg.fix file that I downloaded from github and made my changes. It doesn’t ever look at the file when it goes through even though I have defined it in the “fog.postinit” file like this
. ${postinitpath}patch.fullreg
I am not quite sure what I am missing here…Is there a different version of the fog.man.reg file?
-
Similar concept in this tutorial. https://forums.fogproject.org/topic/14278/creating-custom-hostname-default-for-fog-man-reg
-
@Chris-Whiteley What exactly do you have in
patch.fullreg
? How do you know it’s not being used? -
@Sebastian-Roth The reason I know it’s not being used is because the changes I made are not happening during a full registration and the script “echo’s” are not there. Here is the patch.fullreg
currfile="/bin/fog.man.reg" newfile="${postinitpath}fog.man.reg.fix" . /usr/share/fog/lib/funcs.sh echo "Testing path for our fixed file at ${postinitpath}fog.man.reg.fix" debugPause # Test path and run copy if found and matched. if [[ -r $newfile ]]; then echo "Found file preparing to copy" debugPause cp -f $newfile $currfile >/dev/null 2>&1 [[ ! $? -eq 0 ]] && echo "Copy Failed" || echo "Copy Succeeded" debugPause else echo "Failed to find file sorry" debugPause fi
This was borrowed from Tom Elliot’s post. I tried the very simple one first and that didn’t work, so I tried this one next and the same issue.
-
@Chris-Whiteley so what does your fog.postinit script look like?
Again I’ll refer you to my post: https://forums.fogproject.org/topic/14278/creating-custom-hostname-default-for-fog-man-reg
Specifically look at the fog.patch.customhostname and fog.postinit sections.
-
@george1421 I ended up figuring it out. I had 3 different locations in /images that had the “postinitscripts” folder which I thought was odd. I had it at the root of /images, inside of /images/dev and inside of /images/dev/dev/. I ended up copying the same things into those 2 other folders and now it is working. I am not sure where it is pulling from though.
-
@george1421 I already showed you right in the question I asked, but since you want to see it again:
#!/bin/bash ## This file serves as a starting point to call your custom pre-imaging/post init loading scripts. ## <SCRIPTNAME> should be changed to the script you're planning to use. ## Syntax of post init scripts are #. ${postinitpath}<SCRIPTNAME> . ${postinitpath}patch.fullreg
-
@Chris-Whiteley PostInit pulls from /images/dev/postinitscripts (the ${postinitpath} is defined as this.)
The /images/dev/dev should not exist but won’t hurt anything either.
I’ll paste the code below, but just for understanding of what it does:
It looks for postinit script in /imagesinit based on the type of task.
Capture task:/imagesinit/
mounted would be looking at/images/dev/
Deploy task:/imagesinit/
would be looking at/images/
The code that sets this up:
dots "Running post init scripts" [[ ! -d /imagesinit ]] && mkdir /imagesinit >/dev/null 2>&1 umount /imagesinit >/dev/null 2>&1 mount -o nolock,proto=tcp,rsize=32768,wsize=32768,intr,noatime "$storage" /imagesinit >/tmp/mount-output 2>&1 if [[ $? -eq 0 ]]; then if [[ -f /imagesinit/.mntcheck ]]; then if [[ -f /imagesinit/postinitscripts/fog.postinit ]]; then postinitpath="/imagesinit/postinitscripts/" elif [[ -f /imagesinit/dev/postinitscripts/fog.postinit ]]; then postinitpath="/imagesinit/dev/postinitscripts/" fi . ${postinitpath}fog.postinit fi umount /imagesinit >/dev/null 2>&1 echo "Done" debugPause else echo "Skipped" debugPause fi
-
@Tom-Elliott Thanks Tom for showing that. It looks like mine is pulling from /images/postinitscripts and not the /images/dev/postinitscripts for doing a full host registration and inventory. Is there a way to change “other tag” and other verbiage both in the FOG web and in the database? Basically, I am looking to put certain info inside of FOG and then find a way to export that out to a different system.
For Instance, when my company buys computers, we have to track the Purchase Order (P.O.) they go with. I would like to have one of the prompts be asking for the P.O. and then find a way to export that or send that info to another system.
Is that even possible?
-
@Chris-Whiteley Run the following commands and post output here:
ls -al /images/dev/postinitscripts/ cat /images/dev/postinitscripts/fog.postinit
I just tested and your script works as far as I can see.
-
ls -al /images/dev/postinitscripts/
drwxrwsrwx. 2 fogproject root 70 Nov 3 15:26 . drwsrwsrwx. 4 fogproject root 73 Nov 4 07:45 .. -rwxrwxrwt. 1 fogproject root 10000 Nov 3 15:19 fog.man.reg.fix -rwxrwxrwx. 1 fogproject root 279 Nov 3 15:45 fog.postinit -rwxrwxrwt. 1 fogproject root 502 Nov 3 15:48 patch.fullreg
cat /images/dev/postinitscripts/fog.postinit
#!/bin/bash ## This file serves as a starting point to call your custom pre-imaging/post init loading scripts. ## <SCRIPTNAME> should be changed to the script you're planning to use. ## Syntax of post init scripts are #. ${postinitpath}<SCRIPTNAME> . ${postinitpath}patch.fullreg
-
@Tom-Elliott said in Post Init Script Issues:
It looks for postinit script in /imagesinit based on the type of task.
Capture task: /imagesinit/ mounted would be looking at /images/dev/
Deploy task: /imagesinit/ would be looking at /images/Possibly we need to take this discussion off line but shouldn’t we consider creating a symbolic links between
/images/dev/postinitscripts
and/images/postinitscripts
if the point of view changes between image capture and deployment? This way there is only one location contains the file that are used with both capture and deployment. -
@george1421 Remember that during a capture, the $storage variable is defined, usually:
IPAddress:/images/dev
In the case of a deplooy the $storage variable is defined, usually:
IPAddress:/images
That’s why the checking.
If somebody wants to move the postinit into /images, then it should be symlinked, but that’s beyond our scope. That’s more of a preference .