Hi,
Mwebb_Sureline’s boss here.
I’ve cobbled this together to do what was needed.
It is rather quick and dirty I’m afraid, could probably call “doInventory” and use the results from there to populate the service tag / serial number rather than directly running the dmidecode in the script.
I’ve seen a few people on the forums trying to get something similar working, so here is the code.
Thanks go to @george1421, I modified his script in the post he linked to make this.
(Using SVN rev 5698) I’ve copied fog.man.reg and setup a new custom job for this, the code replaces the hostname input section from fog.man.reg directly, e.g. remove lines 156 to 167 and paste this in.
Whilst this works for us, you use this at your own risk.
while [[ $res != "#!ok" ]]; do
echo " * Retrieving serial number or service tag for this computer to use as hostname "
getserialno=`dmidecode -s chassis-serial-number`;
getserialno="${getserialno%"${getserialno##*[![:space:]]}"}"; # Remove trailing whitespace
# get the serial no from the baseboard if bios doesn't give it up
if [ "$getserialno" = "" ];
then
getserialno=`dmidecode -s baseboard-serial-number`;
getserialno="${getserialno%"${getserialno##*[![:space:]]}"}"; # Remove trailing whitespace
fi
if [[ "$getserialno" = "" || "$getserialno" == "None" ]];
then
echo " * Unable to retrieve tag or serial number, please enter hostname manually. Just hit return to leave blank (will use MAC address)"
read getserialno
getserialno="${getserialno%"${getserialno##*[![:space:]]}"}"; # Remove trailing whitespace
fi
host="$getserialno";
if [[ ${#host} -gt 15 ]]; then
host=${host:0:15}
echo " | Truncated to 15 characters: $host"
usleep 2000000
fi
echo " * Hostname set to: $getserialno"
host=$(echo $host | base64)
res=$(wget --post-data="host=$host" -qO - http://${web}service/hostnameloop.php 2>/dev/null)
[[ $res != "#!ok" ]] && echo "$res"
done