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

FOG post-download script path?

Scheduled Pinned Locked Moved
General Problems
2
3
772
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.
  • D
    david.burgess
    last edited by david.burgess May 12, 2022, 3:38 PM May 12, 2022, 9:37 PM

    I have read a few tutorials about the post-download script, and maybe I’m just too tired to get it, but I am unclear on what path or binaries are available to the script.

    To put my problem in context, I need to wipe the nvme drive in the client after the image is deployed. The OS (Ubuntu) will be installed on a SATA drive, so we’re just wiping the secondary drive and the only nvme device in the host.

    So I’ve added these lines to fog.postdownload:

    drive=`nvme list|awk -F'[/ ]' '/dev/ {print $3}'`
    nvme format $drive
    

    What’s not clear to me is the environment this will run in, and thus where nvme-cli needs to be installed. The host’s OS? FOG?

    G 1 Reply Last reply May 13, 2022, 1:35 AM Reply Quote 0
    • G
      george1421 Moderator @david.burgess
      last edited by May 13, 2022, 1:35 AM

      @david-burgess Postinstall (and PostInit) scripts run in the context of the FOS Linux engine. When you pick a FOG iPXE menu item most download bzImage (the kernel) and init.xz (the virtual hard drive) to the target computer. This is FOS Linux. This is a customized linux OS that is specialized for imaging. This is a FOG Project developers creation.

      So how do you develop a post install script? There is an easy way and a bit harder way. Lets do the easy way.

      On the fog server in /image/postinstallscript directory there is a file called fog.postinstall. Append the following to the end of that script.

      echo "Hey stop me! I'm about to run a post install script"
      debugPause
      

      Now setup a deploy image task, but before you schedule the deploy task button, tick the debug checkbox then schedule the task.

      Now pxe boot the target computer. After several screens of text that you need to clear with the enter key you will be dropped at the FOS Linux command prompt.

      At the FOS Linux command prompt key in fog and press enter.

      You will single step through the deployment. When you see the message “Hey stop me! I’m about to run a post install script” press ctrl-C to exit out of the post install script. At this point you have the current context of where the post install script will run. You can execute linux commands here to do your actions you need. Once you have the exact key sequences you need, back on the FOG server you can create your bash script in the /images/postinstall directory. You can view that directory on the FOS Linux system because its also mapped to /images/postinstallscript on the target computer too. You can not make changes to the script file from FOS Linux because the mount is read only, but you can make changes directly on the FOG Server.

      Now that you perfected your bash script, in the fog.postinstall script after the debugPause command stat your script. So your script is called as in the example in the script. I would also insert another debugPause after your script call so the deployment will pause after your script so you can read any error messages. You can restart this deployment loop as many times as you need until your script runs flawlessly.

      Now that your new bash script is linked in you can restart the image deployment again with fog

      This last part will make copy and pasting during debugging much easier.
      On the FOS Linux computer give root a password (no worries it will be reset when FOS Linux reboots) with passwd give it a simple password like hello. Now get the ip address of the target computer with ip a s
      With that information now use putty from a windows computer or ssh from a linux computer to remote into the target computer to begin your debugging session by issuing the fog command.

      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!

      D 1 Reply Last reply May 16, 2022, 6:51 PM Reply Quote 0
      • D
        david.burgess @george1421
        last edited by May 16, 2022, 6:51 PM

        @george1421

        This is helpful, thanks.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        1 / 1
        • First post
          2/3
          Last post

        165

        Online

        12.0k

        Users

        17.3k

        Topics

        155.2k

        Posts
        Copyright © 2012-2024 FOG Project