• 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?


  • @george1421

    This is helpful, thanks.

  • Moderator

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

266
Online

9.6k
Users

16.0k
Topics

147.9k
Posts