This is from the X86 version under TC4 so I don't know if it's valid under PI. In tc-config:
It looks like if you set the hostname in /etc/hostname and back it up, it will be used if the host boot code exists.
Code on piCore is the same. You also need to look at /usr/bin/sethostname that gets called during bootsync.sh you have to specify the actual hostname on the command line. Editing /etc/hostname and adding to your backup set does nothing. You must specify "host=newname" on the command line to have any affect.
There is a fairly easy solution in adding a handshake between the command /usr/bin/sethostname running and /etc/init.d/dhcp.sh running.
Added at the end of /usr/bin/sethostname
touch /tmp/sethostnameran
Added to the beginning of /etc/init.d/hdcp.sh
CNT=0
until [ -e "/tmp/sethostnameran" ]
do
[ $((CNT++)) -gt 100 ] && break || sleep 0.1
done
rm -fr /tmp/sethostmaneran
There is probably no need for a timeout trap, since sethostname always gets called.....but just incase someone changes /opt/bootsync.sh it will timeout after 10 seconds
And yes, it looks like $HOST is just being recycled.....it is referring the the remote hostname for retrieving apps. It doesn't get used until after the local hostname is set.......so no big deal, but it's a little confusing. (I'm a little fuzzy on variable scope in shell scripts too, but I think it is a local scope too)