davidferguson / pibakery-blocks

All the blocks for the Pi Bakery program
GNU General Public License v3.0
242 stars 86 forks source link

Remove .local from default hostname in "Set hostname" block #16

Closed dkirkby closed 8 years ago

dkirkby commented 8 years ago

The current default hostname in this block is "raspberrypi.local" which suggests that the new name should retain the ".local" extension. Although it appears to work, I don't recommend this since the dot (.) is not actually a valid hostname character, even though raspberrypi.local is often how you will access your Pi using the magic of avahi.

This block runs:

raspi-config nonint do_hostname "$1"

which then writes the specified name into /etc/hosts and /etc/hostsname. An unmodified Pi does not have ".local" in these files, but running this command with the default name adds it to them. The reason this works at all is that /etc/init.d/hostname.sh sanitizes these files during the next boot startup, removing the ".local" extensions.