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

Need to create a While loop on deployment for when an image has not been assigned

Scheduled Pinned Locked Moved Solved
FOG Problems
4
12
713
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.
  • G
    george1421 Moderator
    last edited by george1421 Oct 31, 2019, 5:52 AM Oct 31, 2019, 11:51 AM

    @zaboxmaster said in Need to create a While loop on deployment for when an image has not been assigned:

    " while the $OSID = null then sleep 200 "

    I’m little confused why the OSID would not be assigned since you should pick the image as part of registration. I suppose you could use OSID to check to set if its set but wouldn’t the image id be more appropriate? If the image ID is not set then there is no image assigned.

    Next as I mentioned in another thread, as I remember your while loop doesn’t do anything to update OSID and I don’t know if that variable is dynamic enough for it to be set in another part of FOG that it will fall through to your local variable. Possibly making that curl call to the hostinfo php page and then updating the variables will do it. I don’t know without really looking at the code. But the $OSID variable is local to the master fog script and is set with kernel parameters or the hostinfo.php page. I don’t think its updated dynamically, but I could be wrong.

    While its a matter of programming style but couldn’t this

    while $OSID = null

    be written as this

    while “${OSID}” -eq “”

    But you will still have the issue of $OSID not being updated once the master fog script starts.

    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
    • Q
      Quazz Moderator
      last edited by Quazz Oct 31, 2019, 6:11 AM Oct 31, 2019, 12:06 PM

      @zaboxmaster said in Need to create a While loop on deployment for when an image has not been assigned:

      while the $OSID = null then sleep 200

      That’s because you’re setting the $OSID to null in your while loop, so it will never end.

      A single = means set value to

      Double = (==) means compare strings

      In bash, if you want to check if a variable is ‘null’, you want to do something like (not sure if syntax is 100% correct) (-z checks if the variable is null)

      while [[ -z "$OSID" ]] 
      do 
              sleep 200
      done
      
      1 Reply Last reply Reply Quote 1
      • Z
        zaboxmaster
        last edited by Nov 6, 2019, 9:42 AM

        Sorry I have taken so long to respond.

        Okay so to start I am editing the fog.man.reg file. I have do this with help from George.

        I have taken away the option to select which image to deploy this was done because, non technical people are using the system and I will decide which image to install for them. I have modified my fog.man.reg file to go straight into the deployment with out rebooting by call on the fog.download. This works fine but what I am looking for is a way of not proceeding to the fog.download file until I have remotely assign an image to be deployed.

        So regarding the while loop

        I have tried the following commands in the fog.man.reg file:
        while [[ -z “$OSID”]]; do
        echo “Please wait”
        sleep 60
        done
        (this failed as the syntax is incorrect)

        while $OSID==“0” ; do

        I have also looked through the fog.checkin file and found a command that i put into the fog.checkin file

        while [[-z $osid]]; do
        echo “Please Wait”
        [[ -z $deployed ]] && determineOS “$osid”
        sleep 60
        done

        Does this help ?

        Q 1 Reply Last reply Nov 6, 2019, 9:50 AM Reply Quote 0
        • Q
          Quazz Moderator @zaboxmaster
          last edited by Nov 6, 2019, 9:50 AM

          @zaboxmaster So what doesn’t work?

          Does it not wait? Does it get stuck on waiting? It’s unclear which part “doesn’t work”

          Z 1 Reply Last reply Nov 6, 2019, 9:56 AM Reply Quote 0
          • Z
            zaboxmaster @Quazz
            last edited by zaboxmaster Nov 6, 2019, 3:57 AM Nov 6, 2019, 9:56 AM

            @Quazz Sorry it skips right past and continues. Its does not pause or wait.

            Q 1 Reply Last reply Nov 6, 2019, 10:18 AM Reply Quote 0
            • Q
              Quazz Moderator @zaboxmaster
              last edited by Nov 6, 2019, 10:18 AM

              @zaboxmaster Alright. I do think $osid should be in lowercase to start off with.

              Does the checkin file work or does that one also not work?

              All that said, I’m not entirely sure if this will work, though I admit my knowledge in this area isn’t great.

              I don’t know if the osid is ever even passed into this area of FOS.

              The imageid might be a better bet.

              Z 1 Reply Last reply Nov 6, 2019, 11:27 AM Reply Quote 0
              • Z
                zaboxmaster @Quazz
                last edited by Nov 6, 2019, 11:27 AM

                @Quazz Okay so I have tried using Imageid but in the fog.man.reg, I will try this in the fog.checkin file. As osid in the fog.checkin did not work either. It just skipped through

                One thing I am not sure of is how the following works,

                [[ -z $deployed ]] && determineOS “$osid”

                I would think that hold the key

                Z 1 Reply Last reply Nov 6, 2019, 12:30 PM Reply Quote 0
                • Z
                  zaboxmaster @zaboxmaster
                  last edited by Nov 6, 2019, 12:30 PM

                  @zaboxmaster said in Need to create a While loop on deployment for when an image has not been assigned:

                  @Quazz Okay so I have tried using Imageid but in the fog.man.reg, I will try this in the fog.checkin file. As osid in the fog.checkin did not work either. It just skipped through

                  One thing I am not sure of is how the following works,

                  [[ -z $deployed ]] && determineOS “$osid”

                  I would think that hold the key

                  So I tried the following

                  while [[ $imageid -le 10 ]]; do
                  if [[ -z “$imageid” ]]
                  then
                  echo “Please Wait”
                  sleep 60
                  fi
                  done

                  Sorry i really do not have the greatest bash skills. But it works but the problem is I need a way to check the variable. In the loop. This is where i get really stuck. Would a curl command to the server to check the variable work ? If so what would that command be ?

                  1 Reply Last reply Reply Quote 0
                  • Z
                    zaboxmaster
                    last edited by Nov 6, 2019, 2:06 PM

                    By any chance do you know where the determineOS function is located ?

                    Q 1 Reply Last reply Nov 6, 2019, 4:19 PM Reply Quote 0
                    • Q
                      Quazz Moderator @zaboxmaster
                      last edited by Nov 6, 2019, 4:19 PM

                      @zaboxmaster /usr/share/fog/lib/funcs.sh

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

                      159

                      Online

                      12.0k

                      Users

                      17.3k

                      Topics

                      155.2k

                      Posts
                      Copyright © 2012-2024 FOG Project