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

Windows Batch Create/update host

Scheduled Pinned Locked Moved
Feature Request
3
11
5.6k
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.
  • W
    Wolfbane8653 Developer
    last edited by Apr 9, 2014, 6:49 PM

    I would like to create a batch file to create or update hosts in fog’s database.

    I would simply still ask the same questions:
    Computer NAME == %computername%
    IMAGE FILE#:
    Add to AD [y/n]: Y

    Grab the LAN MAC using:
    [QUOTE]
    @echo off
    set mac=&set ealac=
    for /f “tokens=1,2 delims=:” %%i in ( ’ ipconfig /all^|findstr /c:“Ethernet adapter” /c:“Physical Address” ’ ) do (
    if defined ealac if not defined mac set mac=%%j
    if not defined ealac if “%%i”==“Ethernet adapter Local Area Connection” set ealac=Y
    )
    echo %mac%
    set ealac=
    [/QUOTE]

    Image now [y/n]?

    1 Reply Last reply Reply Quote 0
    • W
      Wolfbane8653 Developer
      last edited by Apr 9, 2014, 6:58 PM

      seems like this was already working at one time or another with the Fog Client Host Registration but was disable.

      [url]http://fogproject.org/forum/threads/fog-client-and-host-registration.793/[/url]

      Was this fixed in the newest client?

      1 Reply Last reply Reply Quote 0
      • T
        Tom Elliott
        last edited by Apr 9, 2014, 9:12 PM

        It wasn’t fixed or set within the client, though I believe when the “host” registers to the system, it passes all of it’s MAC’s to the FOG Server. The FOG Server then parses this information and finds the relevant host based on “all” of the MAC’s sent to FOG. If it finds one, and another MAC is not found, it should place it in the Pending MAC’s field. FOG 0.33b will find a host no matter what MAC is sent to it so long as that MAC is assigned to a host (not in pending state). So really this should be working to at least still do snapin/task checkins even if wireless.

        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
        • W
          Wolfbane8653 Developer
          last edited by Apr 10, 2014, 12:38 PM

          So is there any way that I can collect the data required for a Host Registration (e.g. Full Inventory Registration) and send it to the fog database using a bat file?

          1 Reply Last reply Reply Quote 0
          • T
            Tom Elliott
            last edited by Apr 11, 2014, 10:22 AM

            I don’t know. The utility FOG uses during an inventory job is dmidecode, I don’t know of the equivalent command under Windows. That said, if the host is already registered, why not just schedule an Inventory Task form the Tasks menu option?

            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
            • C
              chad-bisd Moderator
              last edited by Apr 14, 2014, 5:04 PM

              What you’re trying to do might be possible if you can get the hostname, mac, imageID, OS ID, and answer to “image now?” question. You just need to collect this information and then send it to the proper web scripts, imitating what the FOG scripts do from within the init.gz.

              Registering a host is basically passing info to a web page, processing the result, and moving to the next step to setup the image task. If you look at how the scripts in the init.gz do it, then you can “fake it” as long as you can collect and submit the data to the same URL from your batch file.


              If you would like to make a donation to the Fog project, please do so [U][COLOR=#0000ff][URL='http://sourceforge.net/dona…

              1 Reply Last reply Reply Quote 0
              • W
                Wolfbane8653 Developer
                last edited by Apr 15, 2014, 2:14 PM

                Chad,

                init.gz is no more. Tom has changed init.gz to init.xz. I just need the info to connect to the fog server, open the correct scripts, input the data, update the database and close the connection.

                So what scripts for init.xz initialize when selecting “Full Host Registration”?

                1 Reply Last reply Reply Quote 0
                • W
                  Wolfbane8653 Developer
                  last edited by Apr 15, 2014, 2:46 PM

                  I see that you must have php installed on the windows machine before you can pass variables from a batch to a php page. Looks like to me that I’m going at this wrong. I think I just use a batch file to launch a webpage for auto registration.

                  Seems like there is something that can be done to change the auto.register.php file.

                  So if I would visit this webpage it would register the client?

                  hmmmmm…looks like it needs some modding for my purposes. What else uses this file???

                  1 Reply Last reply Reply Quote 0
                  • C
                    chad-bisd Moderator
                    last edited by Apr 15, 2014, 2:51 PM

                    If you look at the main bing/fog script in the init file, look for the code that handles the mode=manreg, I believe it calls fog.man.reg script. In that script, you can follow it along as it prompts for options and then submits those to the web server for registration, then calls doInventory, then submits the inventory info to the server. Somewhere in there, the option to image now is given and the result is either passed along, or used to call a web script that sets up the imaging task.


                    If you would like to make a donation to the Fog project, please do so [U][COLOR=#0000ff][URL='http://sourceforge.net/dona…

                    1 Reply Last reply Reply Quote 0
                    • C
                      chad-bisd Moderator
                      last edited by Apr 15, 2014, 2:53 PM

                      You’ll need something on the windows side that can imitate wget for querying the fog server for image and os info, and can submit the results in POST format back to the fog server. The inventory part, I’m not sure, it might just be easier to avoid that during registration and call a hardware inventory task later.


                      If you would like to make a donation to the Fog project, please do so [U][COLOR=#0000ff][URL='http://sourceforge.net/dona…

                      1 Reply Last reply Reply Quote 0
                      • W
                        Wolfbane8653 Developer
                        last edited by Jun 2, 2014, 5:03 PM

                        Since I reformatted my fog server and did a complete new install from Fog 0.32 --> 0.33 --> 1.0.0 --> 1.0.1–>1.1.0, I have lost my client list. 😞 I originally hoped the client would re-register themselves but that function was lost in 0.29 and it makes sense why. The HOST has no idea what image to point to. Considering there may be 2 possible images for the same Make\Model of machine.

                        So I wanted to make this easier on myself.

                        Here is what I came up with… I have a shortcut to a network shared batch file so I can make some changes on the fly with our users that can’t do things for themselves. This batch file is in windows All Users\Startup folder. (Dirty I know but works). SO if I want my staff to look at a webpage as soon as they log in I can force that. 🙂

                        [B]Windows Batch file:[/B]
                        [CODE]start <fogserverip>/fog/management/index.php?node=host&sub=add[/CODE]

                        [B]Install arpscan to fog server[/B]
                        [CODE]sudo apt-get install arp
                        [/CODE]

                        [B]Edit /var/www/fog/lib/pages/[/B][B]HostManagementPage.class.php[/B] to include just below print “\n\t\t\t<h2>”._(‘Add new host definition’).‘</h2>’;
                        [CODE] //----------------------------------------------------------------------------------------
                        //Register this host Button (wolfbane8653)
                        //Must install arp first (sudo apt-get install arp) before enabling this button
                        ?>
                        <script>
                        function fillinfo()
                        {
                        //get this hosts info
                        <?php
                        $ipaddr = $_SERVER[‘REMOTE_ADDR’];
                        $chk = exec('/usr/sbin/arp -a '.$ipaddr,$output);
                        $data = explode(" “,$output[0]);
                        $name = explode(”.",$data[0]);
                        $hostname = $name[0];
                        $macaddr = $data[3];
                        ?>
                        //export php info into javascript
                        var hostname = “<?php echo $hostname ?>”;
                        var macaddr = “<?php echo $macaddr ?>”;
                        //output to textboxes
                        document.getElementsByName(“host”)[0].value=hostname;
                        document.getElementsByName(“mac”)[0].value=macaddr;
                        }
                        </script>
                        <button onclick=“fillinfo()”>Register THIS HOST</button>
                        <?php
                        //end button
                        //----------------------------------------------------------------------------------------[/CODE]

                        With this edit I now can click on this new button and it inputs my current computer name and mac address in the correct fields. Is there anyway this can be incorporated as a hook/plugin/option?

                        [COLOR=#ff0000]Warning this only works on LAN.[/COLOR]

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

                        159

                        Online

                        12.0k

                        Users

                        17.3k

                        Topics

                        155.2k

                        Posts
                        Copyright © 2012-2024 FOG Project