Pass ${fog-ip} to Install Script as a Variable


  • Hello All - I am attempting to pass the Fog Server host IP ${fog-ip} to an answerfile / Bash Script, so I do not have to manually edit the Fog Server IP in the script of the installer each time the fog IP changes (Long story).

    I tried passing as a variable using the kernel option such as at the end I put “thefogip=${fog-ip}” :
    kernel http://${fog-ip}/iso/xen80/boot/xen dom0_max_vcpus=4 dom0_mem=max:4096M com1=115200,8n1 console=com1,vga thefogip=${fog-ip}

    Then in my answer file (XML) I tried to reference it with :
    <script stage=“filesystem-populated” type=“url”>http://$thefogip/iso/xen80/scripts/post-script.sh</script>

    But the variable did not seem to populate…
    I also looked at this Post, but I am likely too ignorant to follow it.
    https://forums.fogproject.org/topic/11014/passing-host-variable-to-ipxe-menu/4

    Thanks!


  • @george1421 That is VERY CLEAR, thank you very much. Will reference the link and see if I can get my head around it. I appreciate your time and knowledge.

  • Moderator

    While I’m not familiar with what you are trying to do, but I have a little insight.

    In the ipxe menu the ${fog-ip} is an ipxe menu run time variable as you see. So you are passing it as a kernel parameter here:

    kernel http://${fog-ip}/iso/xen80/boot/xen dom0_max_vcpus=4 dom0_mem=max:4096M com1=115200,8n1 console=com1,vga thefogip=${fog-ip}
    

    So the xen kernel will see a kernel parameter of thefogip and its IP address. So inside of the running xen OS you will need to read the kernel parameters and turn that into a bash variable.

    So how does FOS Linux do this? If you look at this URL: https://github.com/FOGProject/fos/blob/master/Buildroot/board/FOG/FOS/rootfs_overlay/usr/share/fog/lib/funcs.sh#L8

    You will see that the fog script runs cat /proc/cmdline to get the kernel parameters and that section from line 8 to 12 converts each kernel parameter into a bash variable and exports it. You will need to do something similar in your code within your xen kernel

364
Online

8.2k
Users

15.0k
Topics

141.5k
Posts