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. -
@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/…
-
@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
-
@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.
-
@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"
-
@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?
-
@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.
-
@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”
-
@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
-
@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"
-
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.
-
@george1421 said in Extended fog variables problem.:
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 -
@greg-plamondon Thank you I’ll update the tutorial with the new information too.