@sebastian-roth
Update I was able to make progress by fixing up the code per-say. I think the OP of the code (ch3i) wrote up something from memory and not from actual tests, and possibly update or make note of any changes in syntax as programs update.
For instance, hostname --fqdn gives an error “hostname: unrecognized option ‘–fqdn’ BusyBox v1.31.1” so I changed to ‘hostname -f’.
I was able to get pass the original MySQL errors using your advice, and using the fogstorage account instead. Running both scripts on ubuntu still stops without reason at “checking hostname/domain configurations”. When I run it on FOG (As a postdownloadscript), and it runs after cloning the image,it stops at :
“Check Mysql Configuration: Done
Check FOG Mysql Database Status: Done
Checking hostname/domain configurations *Rebooting system as task is completed”
Reboot: restarting system
but upon reboot, I have the same hostname I myself set prior to capturing the image. Fog has a different hostname set to the MAC that I never changed, so if the script worked my hostname should reflect what FOG has.
IT never makes it to the next part which should say “updating /etc/hostname” nor saying “Done” or “host not found in fog database”. So I am thinking it’s stuck at these lines:
#########################################################
# Get interfaces
#########################################################
NETWORK_CARDS=($(ls /sys/class/net | grep eth))
#########################################################
# Get host name and domain from FoG database
#########################################################
FUNC_DOTS "Checking hostname/domain configurations"
for ETH in ${NETWORK_CARDS[*]}
do
# read mac address
MAC=$(cat /sys/class/net/$ETH/address)
# get mac address information from fog web server
wget http://$FOG_SERVER/$FOG_WEBROOT/service/hostname.php?mac=$MAC -O /tmp/hostname_check 2>/dev/null
HOST_NAME="$(grep 'ok=' /tmp/hostname_check | cut -d "=" -f2)"
HOST_DOMAIN_NAME="$(grep 'ADDom' /tmp/hostname_check | cut -d "=" -f2)"
if [ "$HOST_NAME" != "" ]
then
echo "Done ($HOST_NAME.$HOST_DOMAIN_NAME)"
sleep 3
# A hostname is found - quit the loop
break
else
echo "Error"
FUNC_DOTS "Host not found in FOG database"
echo "exiting"
sleep 3
exit
fi
done
Final Update
I got it to work!
As first mentioned, I had to update the syntax as it’s been over 7 years since the code was written by OP (ch3i). The update that crashed the above code was :
NETWORK_CARDS=($(ls /sys/class/net | grep eth))
To get it to work I swapped it to :
NETWORK_CARDS=($(ls /sys/class/net ))
I learned thru google there was a change (systemd?) that made ls /sys/class/net not use ETH anymore, rather showing something like “enp0s31f6” which is the same as ETH0, but showing the exact location. The code was looking for ETH so just removing that line fixed it.
Now that it works, I feel I can turn the code into a snap-in or post-download script.