Dynamically Patching FOS using a PostInit script


  • Moderator

    Under Construction

    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 here

    The 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.

    1. Create a file /images/dev/postinitscripts/fog.patch.man.reg
    2. 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
    
    echo "Testing path for our fixed file at ${newfile}"
    debugPause
    
    # Test path and run copy if found and matched.
    if [[ -r $newfile ]]; then
        echo "Found source 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 [${newfile}] sorry. Copy Failed"
        debugPause
    fi
    
    
    1. Make the script executable chmod 755 /images/dev/postinit/fog.patch.man.reg
    2. Edit '/images/dev/postinit/fog.postinit`
    3. 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.

    <I stopped here for script validation>

    Original script credit Tom Elliot
    ref: https://forums.fogproject.org/topic/9754/custom-full-host-registration-for-1-3-4/46


Log in to reply
 

453
Online

6.3k
Users

13.8k
Topics

130.0k
Posts