#!/bin/bash zmyip=`ip route get 8.8.8.8 | awk 'NR==1 {print $NF}' | cut -d "." -f1-2`; case "${zmyip}" in 10.1) zsitecode="NYC"; ;; 10.2) zsitecode="LA"; ;; *) # Default code for the unknowns zsitecode="CRP"; ;; esac zchassis=`dmidecode -s chassis-type`; zchassis="${zchassis%"${zchassis##*[![:space:]]}"}"; #Remove training space zchassis="${zchassis,,}"; # Convert string to lower if [ "$zchassis" == "laptop" ]; then zchtype="P"; elif [ "$zchassis" == "tablet" ]; then zchtype="T"; else # Everything else is a desktop zchtype="D"; fi zserialno=`dmidecode -s chassis-serial-number`; zserialno="${zserialno%"${zserialno##*[![:space:]]}"}"; # Remove trailing whitespace # get the serial no from the baseboard if chassis doesn't give it up if [ "$zserialno" == "" ]; then zserialno=`dmidecode -s baseboard-serial-number`; zserialno="${zserialno%"${zserialno##*[![:space:]]}"}"; fi LEN=$(echo ${#zserialno}); if [ "$LEN" -gt 11 ]; then # get the right most characters of the serial number (usually the most # unique characters). Logic for 11 is Site(3)+HW(1)+Serial(11)=15 characters zserialno=${zserialno:(-11)}; fi # default host name is returned to the fog.man.reg script host_default_name="$zserialno";