Part 5 Access FOG host data
A new feature has been added to the FOG 1.2.0 trunk build starting at r8950. With r8050 FOS can now request host specific data from the FOG server. For example, lets say you entered some data into the other and other1 fields in the host record. You can now access them in your post install script. The following code snippet will request the host info for the computer FOS is imaging.
The code says (in english) if the $mac variable is defined then call the FOG server with the mac address and output the results into a file. Then we’re going to stat that file file. The results is FOS will create a variable list of all of the host info for you to use in your script.
Using FOG 1.4.1 and earlier you should use this code:
if [[ ! -z $mac ]]; then
wget -q -O /tmp/hinfo.txt "http://${web}service/hostinfo.php?mac=$mac"
if [[ -f /tmp/hinfo.txt ]]; then
. /tmp/hinfo.txt
fi
fi
As of FOG 1.4.2 curl is preferred over wget. Also the structure of the ${web} variable has changed. Using curl and the updated contents of ${web} we would update the above script to this:
if [[ ! -z $mac ]]; then
curl -A "" -Lkso /tmp/hinfo.sh ${web}/fog/service/hinfo.php -d "mac=$mac"
if [[ -f /tmp/hinfo.sh ]]; then
. /tmp/hinfo.sh
fi
fi
After running the above script these additional variables are available for use in your post install script.
shutdown # Shut down at the end of imaging
hostdesc #Host Description from Host Managment-General
hostip # IP address of the FOS client
hostimageid # ID of image being deployed
hostbuilding # ??
hostusead # Join Domain after image task from Host Management-Active Directory
hostaddomain # Domain name from Host Management-Active Directory
hostaduser # Domain Username from Host Management-Active Directory
hostadou # Organizational Unit from Host Management-Active Directory
hostproductkey= # Host Product Key from Host Management-Active Directory
imagename # Image Name from Image Management-General
imagedesc # Image Description from Image Management-General
imageosid # Operating System from Image Management-General
imagepath # Image Path from Image Management-General (/images/ assumed)
primaryuser # Primary User from Host Management-Inventory
othertag # Other Tag #1 User from Host Management-Inventory
othertag1 # Other Tag #2 from Host Management-Inventory
sysman # System Manufacturer from Host Management-Inventory (from SMBIOS)
sysproduct # System Product from Host Management-Inventory (from SMBIOS)
sysserial # System Serial Number from Host Management-Inventory (from SMBIOS)
mbman # Motherboard Manufacturer from Host Management-Inventory (from SMBIOS)
mbserial # Motherboard Serial Number from Host Management-Inventory (from SMBIOS)
mbasset # Motherboard Asset Tag from Host Management-Inventory (from SMBIOS)
mbproductname # Motherboard Product Name from Host Management-Inventory (from SMBIOS)
caseman # Chassis Manufacturer from Host Management-Inventory (from SMBIOS)
caseserial # Chassis Serial from Host Management-Inventory (from SMBIOS)
caseasset # Chassis Asset from Host Management-Inventory (from SMBIOS)
location # Host Location (name) from Host Management-General
(pause)
drive.
And why fog stable?