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

    Join Domain/Customize Computer Name without Host Registration

    Scheduled Pinned Locked Moved Solved
    FOG Problems
    2
    11
    1.2k
    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.
    • C
      ConJon
      last edited by

      Just like the title says, is there a way to customize the computer name and join a domain without registering the pc? Maybe just a dialog box at the beginning and an automatic domain join at the end? Registering is pointless for us because we only image new laptops that we purchase. We don’t have anything to do with the machines when they come back. So going through the registering process is pointless.

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

        What would you name the machines (give example)? Is it something that can be calculated?

        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!

        C 1 Reply Last reply Reply Quote 0
        • C
          ConJon
          last edited by

          This post is deleted!
          1 Reply Last reply Reply Quote 0
          • C
            ConJon @george1421
            last edited by

            @george1421 We name them in a numeric sequence. It’s (Name of Company)-115121, the next laptop is (Name of company)-115122, and the next one is (Name of Company)-115123, and so on so fourth.

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

              @ConJon ok then probably your best route is to create a post install script. That script (bash shell script) runs after the image has been pushed to the target computer and before the target computer reboots leaving FOS.

              This post install script should ask for computer name. And then take the returned results, display it for the user to confirm, and then finally update the unattend.xml file with the computer name. This way when windows setup and OOBE runs it reads the host name from the unattend.xml file and renames the computer properly.

              The update unattend.xml part is not hard. I have a tutorial on post install scripts here: https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed the script in question is fog.updateunattend.

              The code fragment that is important (outside of some setup code) is this:

              sed -i "/ComputerName/s/*/$hostname/g" $unattend >/dev/null 2>&1
              

              With that one command it will search the unattend file and replace </ComputerName>*</ComputerName> with </ComputerName>computername</ComputerName> or what ever is in the variable $hostname. That variable $hostname will come from the prompt to the IT admin.

              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!

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

                If you look at the FOG Project github site, specifically this file: https://github.com/FOGProject/fos/blob/master/Buildroot/board/FOG/FOS/rootfs_overlay/bin/fog.man.reg at line 160 https://github.com/FOGProject/fos/blob/master/Buildroot/board/FOG/FOS/rootfs_overlay/bin/fog.man.reg#L160

                You will see where the full registration script asks the user for the computer’s host name.

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

                Now all you need is to glue the bits together.

                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
                • george1421G
                  george1421 Moderator
                  last edited by

                  I mashed up the two scripts to make this:

                  #!/bin/bash
                  . /usr/share/fog/lib/funcs.sh
                  [[ -z $postdownpath ]] && postdownpath="/images/postdownloadscripts/"
                  case $osid in
                      5|6|7|9)
                          clear
                          [[ ! -d /ntfs ]] && mkdir -p /ntfs
                          getHardDisk
                          if [[ -z $hd ]]; then
                              handleError "Could not find hdd to use"
                          fi
                          getPartitions $hd
                          for part in $parts; do
                              umount /ntfs >/dev/null 2>&1
                              fsTypeSetting "$part"
                              case $fstype in
                                  ntfs)
                                      dots "Testing partition $part"
                                      ntfs-3g -o force,rw $part /ntfs
                                      ntfsstatus="$?"
                                      if [[ ! $ntfsstatus -eq 0 ]]; then
                                          echo "Skipped"
                                          continue
                                      fi
                                      if [[ ! -d /ntfs/windows && ! -d /ntfs/Windows && ! -d /ntfs/WINDOWS ]]; then
                                          echo "Not found"
                                          umount /ntfs >/dev/null 2>&1
                                          continue
                                      fi
                                      echo "Success"
                                      break
                                      ;;
                                  *)
                                      echo " * Partition $part not NTFS filesystem"
                                      ;;
                              esac
                          done
                          if [[ ! $ntfsstatus -eq 0 ]]; then
                              echo "Failed"
                              debugPause
                              handleError "Failed to mount $part ($0)\n    Args: $*"
                          fi
                          echo "Done"
                          debugPause
                          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=$(curl -Lks --data "host=$host" ${web}service/hostnameloop.php 2>/dev/null)
                              [[ $res != "#!ok" ]] && echo "$res"
                          done
                          unattends=$(find /ntfs/ -iname "unattend.xml")
                          for unattend in $unattends
                              [[ ! -f $unattend ]] && return
                              dots "Writing Computer Name to $unattend"
                              sed -i "/ComputerName/s/*/$host/g" $unattend >/dev/null 2>&1
                              if [[ ! $? -eq 0 ]]; then
                                  echo "Failed"
                                  debugPause
                                  handleError "Failed to update originating unattend file"
                              fi
                              echo "Done"
                              echo "ComputerName set to $host in $unattend"
                              debugPause
                          done
                          umount /ntfs
                          ;;
                      *)
                          echo "Non-Windows Deployment"
                          debugPause
                          return
                          ;;
                  esac
                  
                  

                  Will it work?? I put no effort into debugging it, but in theory the logic looks right.

                  This file should be saved as fog.custominstall in /images/postinstallscripts. Its mode changed to 777 and the fog.postinstall script updated to call this fog.custominstall script as outlined in the tutorial.

                  The only thing you need to ensure is that your unattend.xml file has the default host name set to star ( * ) which tells windows to pick a random name. This script will replace the star ( * ) with the name provided in the script. The deployment will pause at this point in the script until the IT admin enters a value is the only caveat I see.

                  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!

                  C 2 Replies Last reply Reply Quote 0
                  • C
                    ConJon @george1421
                    last edited by

                    @george1421 Thank you very much! Sorry for the late reply. It’s been very busy lately. We have been swapping out switches and equipment and Access Points and Printers. Just been a hectic couple of weeks

                    1 Reply Last reply Reply Quote 0
                    • C
                      ConJon @george1421
                      last edited by

                      @george1421 Is it possible to combine this with the driver injection, as having driver injection is still a good idea to have in my opinion.

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

                        @ConJon Yes that is already part of the scripts at the link provided in a previous post below. I’ll link it again here: https://forums.fogproject.org/topic/11126/using-fog-postinstall-scripts-for-windows-driver-injection-2017-ed

                        Its covered in the fog.updateunattend script section. You will probably want to remove the non-value added parts of that script like connecting to AD and such.

                        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!

                        C 1 Reply Last reply Reply Quote 0
                        • C
                          ConJon @george1421
                          last edited by

                          @george1421 Oh, my apologies. Thank you very much for your help. You’re truly a wizard as your profile picture shows. 😉 Thank you again!

                          1 Reply Last reply Reply Quote 1
                          • 1 / 1
                          • First post
                            Last post

                          156

                          Online

                          12.0k

                          Users

                          17.3k

                          Topics

                          155.2k

                          Posts
                          Copyright © 2012-2024 FOG Project