This script will run at boot time and check that the hostname of the device is based on the serial number. If not it will change the hotname and reboot.
git clone https://github.com/gavuk/barm-unique-hostname.git
cd barm-unique-hostname
./install.sh