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

Extended fog variables problem.

Scheduled Pinned Locked Moved Solved
General
3
14
1.3k
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
    Greg Plamondon Testers
    last edited by Apr 30, 2018, 4:50 PM

    I have used this in the past to get additional information on a host but it doesn’t work any longer.
    https://forums.fogproject.org/topic/7740/the-magical-mystical-fog-post-download-script/3
    the /tmp/hinfo.txt file isn’t created and after executing the wget command from debug i get this:

    wget -q -O /tmp/hinfo.txt "http://${web}service/hostinfo.php?mac=$mac"
    wget: bad port spec 'http:'
    

    any help would be greatly appreciated.

    T 1 Reply Last reply Apr 30, 2018, 6:11 PM Reply Quote 0
    • G
      george1421 Moderator
      last edited by Apr 30, 2018, 5:21 PM

      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!

      G 1 Reply Last reply Apr 30, 2018, 7:17 PM Reply Quote 0
      • T
        Tom Elliott @Greg Plamondon
        last edited by Apr 30, 2018, 6:11 PM

        @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
        • G
          Greg Plamondon Testers @george1421
          last edited by Greg Plamondon Apr 30, 2018, 1:19 PM Apr 30, 2018, 7:17 PM

          @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
          
          G 1 Reply Last reply Apr 30, 2018, 7:22 PM Reply Quote 0
          • G
            george1421 Moderator @Greg Plamondon
            last edited by Apr 30, 2018, 7:22 PM

            @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!

            G 1 Reply Last reply Apr 30, 2018, 7:30 PM Reply Quote 0
            • G
              george1421 Moderator @george1421
              last edited by Apr 30, 2018, 7:30 PM

              @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!

              G 1 Reply Last reply Apr 30, 2018, 7:32 PM Reply Quote 0
              • G
                Greg Plamondon Testers @george1421
                last edited by Apr 30, 2018, 7:32 PM

                @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?

                G T G 3 Replies Last reply Apr 30, 2018, 7:37 PM Reply Quote 0
                • G
                  george1421 Moderator @Greg Plamondon
                  last edited by george1421 Apr 30, 2018, 1:37 PM Apr 30, 2018, 7:37 PM

                  @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
                  • T
                    Tom Elliott @Greg Plamondon
                    last edited by Apr 30, 2018, 7:38 PM

                    @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
                    • G
                      Greg Plamondon Testers
                      last edited by Greg Plamondon May 1, 2018, 6:51 AM May 1, 2018, 12:39 PM

                      @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
                      • G
                        Greg Plamondon Testers @Greg Plamondon
                        last edited by Greg Plamondon May 1, 2018, 7:20 AM May 1, 2018, 12:58 PM

                        @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" 
                        
                        G 1 Reply Last reply May 1, 2018, 1:39 PM Reply Quote 0
                        • G
                          george1421 Moderator @Greg Plamondon
                          last edited by May 1, 2018, 1:39 PM

                          @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!

                          G 1 Reply Last reply May 1, 2018, 1:53 PM Reply Quote 0
                          • G
                            Greg Plamondon Testers @george1421
                            last edited by May 1, 2018, 1:53 PM

                            @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

                            G 1 Reply Last reply May 1, 2018, 1:55 PM Reply Quote 0
                            • G
                              george1421 Moderator @Greg Plamondon
                              last edited by May 1, 2018, 1:55 PM

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

                              185

                              Online

                              12.0k

                              Users

                              17.3k

                              Topics

                              155.2k

                              Posts
                              Copyright © 2012-2024 FOG Project