• 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
    689
    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.
    • Z
      zaboxmaster
      last edited by

      HI guys

      After the host has been registered and is ready for deployment I need to create a While loop to “pause” the deployment until and image has been assigned.

      I have tried to create a while loop using " while the $OSID = null then sleep 200 " but this does not seem to work.

      What is the correct way of doing this?

      1 Reply Last reply Reply Quote 0
      • S
        Sebastian Roth Moderator
        last edited by

        @zaboxmaster As we have dozens of new posts every day you might want to include some more information in your posts to make it easier for us to follow. Due to the lack of information I had a look at your earlier posts and my guess is you are still working on modifying fog.man.reg. Is that right?

        Which version of FOG do you use by the way?

        I have tried to create a while loop using " while the $OSID = null then sleep 200 " but this does not seem to work.

        Please post the exact code you have tried and the result you got!

        If you seem to have issues with the bash scripting syntax then search the web and you’ll find hundreds of great tutorials on how to do while loops!

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

          @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

            @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

              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 Reply Quote 0
              • Q
                Quazz Moderator @zaboxmaster
                last edited by

                @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 Reply Quote 0
                • Z
                  zaboxmaster @Quazz
                  last edited by zaboxmaster

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

                  Q 1 Reply Last reply Reply Quote 0
                  • Q
                    Quazz Moderator @zaboxmaster
                    last edited by

                    @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 Reply Quote 0
                    • Z
                      zaboxmaster @Quazz
                      last edited by

                      @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 Reply Quote 0
                      • Z
                        zaboxmaster @zaboxmaster
                        last edited by

                        @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

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

                          Q 1 Reply Last reply Reply Quote 0
                          • Q
                            Quazz Moderator @zaboxmaster
                            last edited by

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

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

                            151

                            Online

                            12.0k

                            Users

                            17.3k

                            Topics

                            155.2k

                            Posts
                            Copyright © 2012-2024 FOG Project