Dynamically Patching FOS using a PostInit script
-
Postinit scripts are scripts called by FOS just after the FOS Linux system inits and before the main FOS imaging program starts. The postinit scripts give us the opportunity to make adjustments to FOS before imaging occurs. These adjustments can be to initialize raid controllers, bring up specialized hardware, or in the case of this post replace or patch parts of FOS imaging scripts before imaging begins.
One example of patching or replacing FOS components might be if you wanted a customized registration process. The FOG registration process is managed by a FOG script called
fog.man.reg
that’s located in the/bin
in the inits. One way to update this fog.man.reg files is by unpacking the inits, updating the script and then repacking the inits and then moving the inits to the proper location on the FOG server. Instructions on unpacking and packing the inits can be found in the FOG Wiki page hereThe method I’m going to cover here is to place the updated fog.man.reg file on the FOG server in the
/images/dev/postinitscripts
script directory where FOS Linux will see it and execute the postinitscripts before it starts imaging.- Create a file
/images/dev/postinitscripts/fog.patch.man.reg
- Paste the contents below into fog.patch.man.reg
#!/bin/bash # Current File in FOS Linux to be replaced currfile="/bin/fog.man.reg" #Patch file to send to FOS Linux virtual hard drive newfile="${postinitpath}fog.reg.man.fix" # --------------------------------------------- # DO NOT edit any text below this line # --------------------------------------------- . /usr/share/fog/lib/funcs.sh # Test path and run copy if found and matched. if [[ -r $newfile ]]; then cp -f $newfile $currfile >/dev/null 2>&1 [[ ! $? -eq 0 ]] && echo -n "patch copy failed " || echo -n "Patch copy succeeded " else echo -n "Patch not found" debugPause fi debugPause
- Make the script executable
chmod 755 /images/dev/postinitscripts/fog.patch.man.reg
- Edit
/images/dev/postinitscripts/fog.postinit
and add the following line to the bottom of the fog.postinit script
. ${postinitpath}fog.patch.man.reg
note: that leading period is not a mistake it needs to be the first character on that line. Its (dot)(space)${postinitpath} to ensure your custom patch script is called correctly.
- Download the latest version of
fog.man.reg
wget -O /images/dev/postinitscripts/fog.reg.man.fix https://github.com/FOGProject/fos/raw/master/Buildroot/board/FOG/FOS/rootfs_overlay/bin/fog.man.reg chmod 755 /images/dev/postinitscripts/fog.reg.man.fix
- Modify
/images/dev/postinitscripts/fog.reg.man.fix
file as needed…
Original script credit Tom Elliot
ref: https://forums.fogproject.org/topic/9754/custom-full-host-registration-for-1-3-4/46 - Create a file
-