CCR BeagleBone Tools  v0.0.1-2206
Production Tools for BeagleBone Devices
 All Pages
CCR Hostname
See Also
BeagleBone Tools

CCR_Hostname configures a decent hostname for the device. The hostname to use can be specified by the caller, otherwise the default behaviour is to create a unique hostname using the BeagleBone device type combined with the first 4 characters of the machine ID.

Key Description
available since 2017-01
package filename ccr_hostname-xyz.deb
configuration /opt/ccr/files/hostname.ccr
cron job /etc/cron.d/ccr_hostname
scripts /usr/bin/ccr_bbtype.sh
/usr/bin/ccr_hostname.sh [<newhostname>]
examples ccr_bbtype.sh
sudo ccr_hostname.sh k03sensor

The script ccr_bbtype.sh returns a simple 1-word string that describes the BeagleBone device type. For example, it returns BBB for BeagleBone Black, and BBGW for BeagleBone Green Wireless.

The hostname to use is stored in /opt/ccr/files/hostname.ccr. If this file does not exist, then ccr_hostname.sh will call upon ccr_bbtype.sh and attempt to automatically create a semi-descriptive and semi-unique hostname.

To install:

sudo dpkg -i ccr_hostname-*.deb

Then either reboot the device, or manually run the script:

sudo ccr_hostname.sh

The new hostname can also be provided on the command-line when manually calling the script. This will automatically update /opt/ccr/files/hostname.ccr so the name is maintained through a reboot. For example:

sudo ccr_hostname.sh test-device-03
Note
If you manually call ccr_hostname.sh to change the hostname, the command line prompt will only reflect the new name once you log out and log back into the device.

A message is logged to syslog when ccr_hostname.sh changes the hostname:

Jan 8 16:21:07 ccr-bbbw-29e5 ccr[1053]: /usr/bin/ccr_hostname.sh: changing hostname from 'ccr-bbbw-29e5' to 'bbbw-testing'
Jan 8 16:21:07 ccr-bbbw-29e5 systemd[1]: Started Hostname Service.
Jan 8 16:21:07 ccr-bbbw-29e5 systemd-hostnamed[1055]: Changed static host name to 'bbbw-testing'
Jan 8 16:21:07 ccr-bbbw-29e5 systemd-hostnamed[1055]: Changed host name to 'bbbw-testing'

Example hostnames that may be created by default with this package if hostname.ccr does not exist:

  • ccr_bbbw_04e8
  • ccr_bbg_37af
  • ccr_bbb_c1d0
See Also
/opt/ccr/files/hostname.ccr
/etc/machine-id
/var/lib/dbus/machine-id
/etc/hostname
/etc/host