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

    Extended fog variables problem.

    Scheduled Pinned Locked Moved Solved
    General
    3
    14
    1.5k
    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.
    • george1421G
      george1421 Moderator
      last edited by

      It depends on how/where you execute that script. The proper URL for testing is

      http://<fog_server_ip>/fog/service/hostinfo.php?mac=$mac
      

      The bad port makes me thing the parameter ${web} is not being expanded correctly.

      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!

      Greg PlamondonG 1 Reply Last reply Reply Quote 0
      • Tom ElliottT
        Tom Elliott @Greg Plamondon
        last edited by

        @greg-plamondon remove the http from your cmd. We pass in the http:// with the $web variable. So your command is doing http://http://fogserver/…

        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
        • Greg PlamondonG
          Greg Plamondon Testers @george1421
          last edited by Greg Plamondon

          @george1421 said in Extended fog variables problem.:

          It depends on how/where you execute that script. The proper URL for testing is

          http://<fog_server_ip>/fog/service/hostinfo.php?mac=$mac
          

          The bad port makes me thing the parameter ${web} is not being expanded correctly.

          The command echo $web returned the proper server url so I changed it to:

          wget -q -O /tmp/hinfo.txt "$web/service/hostinfo.php?mac=$mac" 
          

          The file hinfo.txt is created in /tmp but if you cat the file you get:

          Cannot view from browser
          
          george1421G 1 Reply Last reply Reply Quote 0
          • george1421G
            george1421 Moderator @Greg Plamondon
            last edited by

            @greg-plamondon Yep its working. You have to pass the calling device as null. I know that doesn’t make sense. Let me look it up.

            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

              @george1421 I don’t have access to the exact code at the moment, but it should be something like this:

              wget -q --user-agent="" -O /tmp/hinfo.txt "$web/service/hostinfo.php?mac=$mac" 
              

              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!

              Greg PlamondonG 1 Reply Last reply Reply Quote 0
              • Greg PlamondonG
                Greg Plamondon Testers @george1421
                last edited by

                @george1421 said in Extended fog variables problem.:

                @george1421 I don’t have access to the exact code at the moment, but it should be something like this:

                wget -q --user-agent="" -O /tmp/hinfo.txt "$web/service/hostinfo.php?mac=$mac" 
                

                and that’s just for testing and i should leave it the other way when using in post init scripts?

                george1421G Tom ElliottT Greg PlamondonG 3 Replies Last reply Reply Quote 0
                • george1421G
                  george1421 Moderator @Greg Plamondon
                  last edited by george1421

                  @greg-plamondon It needs to be left in there. The fog code switched over from wget to curl and the FOG application checks to see if is a browser connecting and blocks it. Its that stupid security stuff again. 😉

                  The --user-agent=“” tells wget to not send (blank) a user agent string.

                  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
                  • Tom ElliottT
                    Tom Elliott @Greg Plamondon
                    last edited by

                    @greg-plamondon it’s preferred to use curl over wget. Curl doesn’t send a user afebt natively so your curl would look something like

                    curl -Lkso /tmp/hinfo.sh ${web}/fog/service/hinfo.php -d “mac=$mac”

                    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 1
                    • Greg PlamondonG
                      Greg Plamondon Testers
                      last edited by Greg Plamondon

                      @tom-elliott said in Extended fog variables problem.:

                      @greg-plamondon it’s preferred to use curl over wget. Curl doesn’t send a user afebt natively so your curl would look something like

                      curl -Lkso /tmp/hinfo.sh ${web}/fog/service/hinfo.php -d “mac=$mac”

                      I get the same result with the above.
                      if I echo $web i get:

                      http://192.168.10.238/fog/
                      

                      I changed what you had to:

                      curl -Lkso /tmp/hinfo.sh ${web}fog/service/hostinfo.php -d "mac=$mac"
                      

                      I create a deploy debug task for a host.
                      I type fog at the shell.
                      i break out of the script after nfs is mounted.
                      I cd to /images/postdownloadscripts
                      ./fog.postdownload
                      my fog.postdown;load looks like:

                      #!/bin/bash
                      . /usr/share/fog/lib/funcs.sh
                      curl -Lkso /tmp/hinfo.sh ${web}fog/service/hostinfo.php -d "mac=$mac"
                      . /tmp/hinfo.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
                                  true
                              done
                              dots "Mounting partition $part"
                              ntfs-3g -o force,rw $part /ntfs >/dev/null 2>&1
                              if [[ ! $? -eq 0 ]]; then
                                  echo "Failed"
                                  debugPause
                                  handleError "Failed to mount $part ($0)\n    Args: $*"
                              fi
                              echo "Done"
                              debugPause
                              pccompany=${hostname:2:1}
                              case $pccompany in
                                              2)
                                      . ${postdownpath}fog.log
                                      . ${postdownpath}fog.bay_replace-files
                                      . ${postdownpath}fog.drivers
                                      . ${postdownpath}fog.ad
                                      ;;
                                              5)
                                      . ${postdownpath}fog.log
                                      . ${postdownpath}fog.canada_replace-files
                                      . ${postdownpath}fog.drivers
                                      . ${postdownpath}fog.ad
                                      ;;
                                              7)
                                      . ${postdownpath}fog.log
                                      . ${postdownpath}fog.jet_replace-files
                                      . ${postdownpath}fog.drivers
                                      . ${postdownpath}fog.ad
                                      ;;
                                              *)
                                      . ${postdownpath}fog.log
                                      . ${postdownpath}fog.replace-files
                                      . ${postdownpath}fog.drivers
                                      . ${postdownpath}fog.ad
                                      ;;
                              esac
                                  umount /ntfs
                              ;;
                          *)
                              echo "Invalid OS"
                              debugPause
                              return
                              ;;
                      esac
                      
                      

                      I then type echo $location and i get nothing…
                      I verified that the /tmp/hinfo.sh exists.
                      If i cat /tmp/hinfo.sh i get:

                      Cannot view from browser
                      
                      1 Reply Last reply Reply Quote 0
                      • Greg PlamondonG
                        Greg Plamondon Testers @Greg Plamondon
                        last edited by Greg Plamondon

                        @greg-plamondon said in Extended fog variables problem.:

                        wget -q --user-agent=“” -O /tmp/hinfo.txt “${web}/service/hostinfo.php?mac=$mac”

                        Thanks @george1421 that worked.
                        do i need to change anything when running that from my fog.postdownload?

                        #!/bin/bash
                        . /usr/share/fog/lib/funcs.sh
                        wget -q --user-agent="" -O /tmp/hinfo.sh "$web/service/hostinfo.php?mac=$mac"
                        . /tmp/hinfo.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
                                    true
                                done
                                dots "Mounting partition $part"
                                ntfs-3g -o force,rw $part /ntfs >/dev/null 2>&1
                                if [[ ! $? -eq 0 ]]; then
                                    echo "Failed"
                                    debugPause
                                    handleError "Failed to mount $part ($0)\n    Args: $*"
                                fi
                                echo "Done"
                                debugPause
                                pccompany=${hostname:2:1}
                                case $pccompany in
                                                2)
                                        . ${postdownpath}fog.log
                                        . ${postdownpath}fog.bay_replace-files
                                        . ${postdownpath}fog.drivers
                                        . ${postdownpath}fog.ad
                                        ;;
                                                5)
                                        . ${postdownpath}fog.log
                                        . ${postdownpath}fog.canada_replace-files
                                        . ${postdownpath}fog.drivers
                                        . ${postdownpath}fog.ad
                                        ;;
                                                7)
                                        . ${postdownpath}fog.log
                                        . ${postdownpath}fog.jet_replace-files
                                        . ${postdownpath}fog.drivers
                                        . ${postdownpath}fog.ad
                                        ;;
                                                *)
                                        . ${postdownpath}fog.log
                                        . ${postdownpath}fog.replace-files
                                        . ${postdownpath}fog.drivers
                                        . ${postdownpath}fog.ad
                                        ;;
                                esac
                                    umount /ntfs
                                ;;
                            *)
                                echo "Invalid OS"
                                debugPause
                                return
                                ;;
                        esac
                        

                        How would I make this use curl?

                        curl -A "" -Lkso /tmp/hinfo.sh ${web}/service/hostinfo.php -d "mac=$mac" 
                        
                        george1421G 1 Reply Last reply Reply Quote 0
                        • george1421G
                          george1421 Moderator @Greg Plamondon
                          last edited by

                          @greg-plamondon

                          Change anything: No you are just telling wget to not pass the user agent parameters to FOG.

                          CURL: Just replace the wget line with the curl line Tom posted. Same results just a different tool. The fog code has been updated (under the hood) to only use curl. There may be a time where curl specific calls are used. But today both work interchangeably.

                          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!

                          Greg PlamondonG 1 Reply Last reply Reply Quote 0
                          • Greg PlamondonG
                            Greg Plamondon Testers @george1421
                            last edited by

                            @george1421 said in Extended fog variables problem.:

                            @greg-plamondon

                            Change anything: No you are just telling wget to not pass the user agent parameters to FOG.

                            CURL: Just replace the wget line with the curl line Tom posted. Same results just a different tool. The fog code has been updated (under the hood) to only use curl. There may be a time where curl specific calls are used. But today both work interchangeably.

                            I had to use the -A option for curl to specify the user agent.

                            curl -A "" -Lkso /tmp/hinfo.sh ${web}/service/hostinfo.php -d "mac=$mac" 
                            

                            That worked like a charm!
                            Thanks @george1421 @Tom-Elliott

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

                              @greg-plamondon Thank you I’ll update the tutorial with the new information too.

                              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
                              • 1 / 1
                              • First post
                                Last post

                              136

                              Online

                              12.2k

                              Users

                              17.3k

                              Topics

                              155.5k

                              Posts
                              Copyright © 2012-2024 FOG Project