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

    Register Host using Chassis Serial number

    Scheduled Pinned Locked Moved
    FOG Problems
    4
    6
    2.0k
    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.
    • M
      Mwebb_Sureline
      last edited by

      Hi All,

      I’ve been trying to adjust fog so when we use a custom fog registration it doesn’t prompt for the Hostname but instead uses the chassis serial number which for Dell’s and HP’s normally relates to the service tag.

      To create the custom.fog.reg I’ve duplicated fog.man.reg and changed line 158 from: ‘read host’

      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)
          res=$(wget --post-data="host=$host" -qO - http://${web}service/hostnameloop.php 2>/dev/null)
          [[ $res != "#!ok" ]] && echo "$res"
      

      To

      # 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)
      #    res=$(wget --post-data="host=$host" -qO - http://${web}service/hostnameloop.php 2>/dev/null)
      #    [[ $res != "#!ok" ]] && echo "$res"
      #done
      host=$(dmidecode -s chassis-serial-number)
      echo “Host: ${host}”
      

      Using the code from funcs.sh to grab the chassis-serial number unfortunately this is not working and the pxe seems to load the BZimage and then just skips to “complete” then reboots.

      Can someone please help?

      Please go easy on my I’m learning as I go here and this is all new territory to me!

      1 Reply Last reply Reply Quote 0
      • Tom ElliottT
        Tom Elliott
        last edited by

        I’m just guessing but you want this on the “full register” and NOT the quick register?

        I haven’t added any magic parsing to the quick install, but FOG has NEVER defined a hostname based on another attribute for the full register. This is because full register is basically waiting for your input – that’s its purpose in life.

        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! Get in contact with me (chat bubble in the top right corner) if you want to join in.

        Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

        Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

        1 Reply Last reply Reply Quote 1
        • M
          Mwebb_Sureline
          last edited by Mwebb_Sureline

          Thanks for the quick response 🙂

          I’d be happy to use quick register, but I can’t see where to change the host from registering with the MAC address and instead register with the Chassis serial number…

          I’d also like it to prompt for which Image ID, but that’s not a must.

          I did have this working on 0.32 using this:

          host=echo $caseserial | base64;

          Tom ElliottT george1421G 2 Replies Last reply Reply Quote 0
          • Tom ElliottT
            Tom Elliott @Mwebb_Sureline
            last edited by

            @Mwebb_Sureline

            The quickregister already has capability to define which image id you want associated with a host (no it’s not customized yet but that’s kind of where capone can come in, though I suppose if you’re actually registering hosts itd be good to have a plugin that works similarly to capone, but allowing registered hosts to operate in much the same way – no that’s a lot of work right now.)

            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! Get in contact with me (chat bubble in the top right corner) if you want to join in.

            Web GUI issue? Please check apache error (debian/ubuntu: /var/log/apache2/error.log, centos/fedora/rhel: /var/log/httpd/error_log) and php-fpm log (/var/log/php*-fpm.log)

            Please support FOG if you like it: https://wiki.fogproject.org/wiki/index.php/Support_FOG

            1 Reply Last reply Reply Quote 0
            • george1421G
              george1421 Moderator @Mwebb_Sureline
              last edited by george1421

              @Mwebb_Sureline That auto naming was a hack in 0.29 and a pseudo feature in 0.30. I do have a feature request out there for this function: https://forums.fogproject.org/topic/6304/fog-2-0-request-advanced-host-naming

              How I handle this today is to do the full registration like Tom suggested. I enter the site prefix and then use a bar code scanner to read the dell asset tag from the back/bottom of the device. Doing it manually works for us now, but I would like to get time to look in the code to see if I could reintegrate this feature into the current build.

              As a side note, I also have a hack that will calculate the name in a post install script that updates the unattend.xml file. The issue is getting FOG to see this new calculated name. It not the best solution but it does work too.

              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 0
              • F
                FredRick
                last edited by

                Hi,

                Mwebb_Sureline’s boss here.

                I’ve cobbled this together to do what was needed.
                It is rather quick and dirty I’m afraid, could probably call “doInventory” and use the results from there to populate the service tag / serial number rather than directly running the dmidecode in the script.

                I’ve seen a few people on the forums trying to get something similar working, so here is the code.
                Thanks go to @george1421, I modified his script in the post he linked to make this.

                (Using SVN rev 5698) I’ve copied fog.man.reg and setup a new custom job for this, the code replaces the hostname input section from fog.man.reg directly, e.g. remove lines 156 to 167 and paste this in.

                Whilst this works for us, you use this at your own risk.

                while [[ $res != "#!ok" ]]; do
                    echo " * Retrieving serial number or service tag for this computer to use as hostname "
                    getserialno=`dmidecode -s chassis-serial-number`;
                    getserialno="${getserialno%"${getserialno##*[![:space:]]}"}";  # Remove trailing whitespace
                    # get the serial no from the baseboard if bios doesn't give it up
                    if [ "$getserialno" = "" ];
                     then
                      getserialno=`dmidecode -s baseboard-serial-number`;
                      getserialno="${getserialno%"${getserialno##*[![:space:]]}"}"; # Remove trailing whitespace
                    fi
                    if [[ "$getserialno" = "" || "$getserialno" == "None" ]];
                     then
                      echo " * Unable to retrieve tag or serial number, please enter hostname manually. Just hit return to leave blank (will use MAC address)"
                      read getserialno
                      getserialno="${getserialno%"${getserialno##*[![:space:]]}"}"; # Remove trailing whitespace
                    fi
                    host="$getserialno";
                    if [[ ${#host} -gt 15 ]]; then
                        host=${host:0:15}
                        echo " | Truncated to 15 characters: $host"
                        usleep 2000000
                    fi
                    echo " * Hostname set to: $getserialno"
                    host=$(echo $host | base64)
                    res=$(wget --post-data="host=$host" -qO - http://${web}service/hostnameloop.php 2>/dev/null)
                    [[ $res != "#!ok" ]] && echo "$res"
                done
                
                1 Reply Last reply Reply Quote 3
                • 1 / 1
                • First post
                  Last post

                232

                Online

                12.0k

                Users

                17.3k

                Topics

                155.2k

                Posts
                Copyright © 2012-2024 FOG Project