• Recent
    • Unsolved
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Dynamically Patching FOS using a PostInit script

    Scheduled Pinned Locked Moved
    Tutorials
    1
    1
    634
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • george1421G
      george1421 Moderator
      last edited by Sebastian Roth

      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
      
      # 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
      
      1. Make the script executable chmod 755 /images/dev/postinitscripts/fog.patch.man.reg
      2. 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.

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

      Please help us build the FOG community with everyone involved. It's not just about coding - way more we need people to test things, update documentation and most importantly work on uniting the community of people enjoying and working on FOG!

      1 Reply Last reply Reply Quote 1
      • george1421G george1421 referenced this topic on
      • 1 / 1
      • First post
        Last post

      267

      Online

      12.0k

      Users

      17.3k

      Topics

      155.2k

      Posts
      Copyright © 2012-2024 FOG Project