Is there a way to make the hostname question REQUIRED for the Full Host Registration questions?



  • People keep leaving it blank and by default it puts the MAC address as the hostname. This is bad because a computer will image and then join the domain with the MAC Address since it becomes the PC name.

    Any way to make “enter hostname” required and not allow someone to just press “enter” while leaving it blank?


  • Moderator

    @george1421 Here is a post and a thread (with developer supplied code) that will hot patch the registration file. This thread was actually someone wanting to create a custom registration process.
    https://forums.fogproject.org/topic/9754/custom-full-host-registration-for-1-3-4/45


  • Moderator

    @vince-villarreal

    Well I have no clue if this will work. But I modified the code using examples around it.

    while [[ $res != "#!ok" ]]; do
        host="";
        while [[ $host == "" ]]; do
            echo -n " * Enter hostname for this computer: "
            read host
            if [[ ${#host} -gt 15 ]]; then
                host=${host:0:15}
                echo " | Truncated to 15 characters: $host"
                usleep 2000000
            fi
            host=$(echo $host | base64)
        done
    
        res=$(curl -Lks --data "host=$host" ${web}service/hostnameloop.php 2>/dev/null)
        [[ $res != "#!ok" ]] && echo "$res"
    done
    

    So what good does this do you?? You might ask.

    Here is what I’m going to recommend.

    1. Download and install notepad++ (required for a happy life)
    2. Go to the page I linked below and click on the raw button in the upper left corner. This will give you just the text of the module.
    3. Copy from the web browser and paste into notepad++
    4. Make the edits I listed above. Its only 3 lines setting hosts to empty, the while and the done.
    5. Save the file as fog.man.reg
      Now here is where things get fun…
    6. Copy that file to the FOG server (you could do all of this on the fog server if it has a gui) into /images/dev/postinitscripts
    7. Now modify (I need to think about the next bit. But the idea is to “hot patch” the FOS engine to apply your custom fog.man.reg file every time FOS boots. FOG has the framework to do this. I just need to get right the first time.)


  • @george1421 yea I see that. I’m not a good programmer as well. If someone knows the command, please feel free to reply within this post.

    I am going to try and google my way through this.


  • Moderator

    I’m not a programmer but this looks like the right spot to add that requriement.

    https://github.com/FOGProject/fos/blob/master/Buildroot/board/FOG/FOS/rootfs_overlay/bin/fog.man.reg

    Line 168.

    ...
    while [[ $res != "#!ok" ]]; do
        echo -n " * Enter hostname for this computer: "
        read host
        if [[ ${#host} -gt 15 ]]; then
            host=${host:0:15}
            echo " | Truncated to 15 characters: $host"
            usleep 2000000
        fi
        host=$(echo $host | base64)
    ->> Need to check here if blank and then loop back to ask again->>
    
        res=$(curl -Lks --data "host=$host" ${web}service/hostnameloop.php 2>/dev/null)
        [[ $res != "#!ok" ]] && echo "$res"
    done
    imageid=""
    ...
    

  • Moderator

    Not currently in FOG, I’m sure if you had a little bash scripting skills it could be done. Let me take a look.


Log in to reply
 

423
Online

6.2k
Users

13.6k
Topics

128.0k
Posts