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

    How to use execute FOG through command line?

    Scheduled Pinned Locked Moved
    Tutorials
    fogapi-psmodule api help api commandline
    6
    9
    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.
    • C
      ChrisK
      last edited by JJ Fullmer

      For example, is it possible to restart a machine and have it reimage itself using a command line approach?

      I am a qa automator and I want to be able to deploy tests onto a specific machine and then have them automatically reimaged when the tests are done running. I am using Jenkins as a deployment server and as far as I know, there is no FOG plugin for Jenkins so I would need to do this through command line.

      1 Reply Last reply Reply Quote 0
      • C
        chad-bisd Moderator
        last edited by

        If you schedule a deploy task and no user is logged in, and you have globally enabled the reboot for scheduled jobs settings, and left it enabled in the client, then within 5 minutes the client should detect it has a job waiting and reboot using whatever boot order you have defined in the bios.

        You can also use the command line tool built into windows since Windows XP: shutdown.exe, provided you have permissions on the remote machine.


        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
          ChrisK
          last edited by

          [quote=“chad-bisd, post: 11463, member: 18”]If you schedule a deploy task and no user is logged in, and you have globally enabled the reboot for scheduled jobs settings, and left it enabled in the client, then within 5 minutes the client should detect it has a job waiting and reboot using whatever boot order you have defined in the bios.

          You can also use the command line tool built into windows since Windows XP: shutdown.exe, provided you have permissions on the remote machine.[/quote]

          Is there a way to deploy a task through command line from the FOG server?

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

            This post is deleted!
            1 Reply Last reply Reply Quote 0
            • C
              chad-bisd Moderator
              last edited by

              not built in, but you can call the php files passing in the correct information, I think.


              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
              • B
                Bjarke
                last edited by

                Perhaps just create a snapin with the requirede command inside, then you can just activate that for the host and it will reboot.

                1 Reply Last reply Reply Quote 0
                • J
                  JaPe
                  last edited by

                  I too am interested in being able specifically to launch deploy task from a command prompt (even if it’s on the FOG server itself). It’s not ideal to just schedule a task on shutdown because I may need to shut down the machine several times before I re-image. Does any one have any other ideas ?

                  george1421G JJ FullmerJ 2 Replies Last reply Reply Quote 0
                  • george1421G
                    george1421 Moderator @JaPe
                    last edited by

                    @jape I’m not sure I understand your issue/quest. You can pxe boot while sitting in front of the computer, then in the FOG iPXE menu pick deploy image. This will not register the target computer with FOG, its simply load and go. This process is used by system remanufacturers to/where fog will never see the target computer again once its imaged.

                    There are a few caveats in using the load and go process in that you can not use the fog client during deployment (because the target computer is never registered with FOG). That also means that snapins will not deploy during image deployment too.

                    If I’ve missed your intent, please explain your problem a bit more.

                    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
                    • JJ FullmerJ
                      JJ Fullmer Testers @JaPe
                      last edited by

                      @jape You can use the api (See the powershell api module links in my signature). You can use it to create the scheduled task. i.e. (provided you got the module all setup prior) the following would create a scheduled deploy task for host with id ‘1234’
                      at 8 pm tonight. The following is all powershell that can be run from your admin workstation.

                      #define the schedule time in the linux format
                      $startAtTime = (get-date 8pm)
                      $EpochDiff = New-TimeSpan "01 January 1970 00:00:00" $($startAtTime)
                      $scheduleTime = [INT] $EpochDiff.TotalSeconds - [timezone]::CurrentTimeZone.GetUtcOffset($(get-date)).totalseconds
                      #define the schedule time in human readable format
                      $runTime = get-date $StartAtTime -Format "yyyy-M-d HH:MM"
                      $jsonData = @"
                                          {
                                              "name":"Deploy Task",
                                              "type":"S",
                                              "taskTypeID":"1",
                                              "runTime":"$runTime",
                                              "scheduleTime":"$scheduleTime",
                                              "isGroupTask":"0",
                                              "hostID":"1234",
                                              "shutdown":"0",
                                              "other2":"0",
                                              "other4":"1",
                                              "isActive":"1"
                                          }
                      "@
                      #create the scheduled deploy task with the defined json
                      New-FogObject -type object -coreObject scheduledtask -jsonData $jsonData
                      

                      Have you tried the FogApi powershell module? It's pretty cool IMHO
                      https://github.com/darksidemilk/FogApi
                      https://fogapi.readthedocs.io/en/latest/
                      https://www.powershellgallery.com/packages/FogApi
                      https://forums.fogproject.org/topic/12026/powershell-api-module

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

                      190

                      Online

                      12.0k

                      Users

                      17.3k

                      Topics

                      155.2k

                      Posts
                      Copyright © 2012-2024 FOG Project