diff --git a/buildroot-external/Config.in b/buildroot-external/Config.in index 0f17d545..88a63e47 100644 --- a/buildroot-external/Config.in +++ b/buildroot-external/Config.in @@ -9,6 +9,7 @@ menu "Additional drivers, libraries and/or applications" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/alsa-plugins/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/btspeaker/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/fann/Config.in" + source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/hostname-service/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/mycroft-mpd/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/respeaker/Config.in" source "$BR2_EXTERNAL_MYCROFTOS_PATH/package/snapcast/Config.in" diff --git a/buildroot-external/configs/rpi4_defconfig b/buildroot-external/configs/rpi4_defconfig index 8d885b79..a131bcdf 100644 --- a/buildroot-external/configs/rpi4_defconfig +++ b/buildroot-external/configs/rpi4_defconfig @@ -394,6 +394,7 @@ BR2_PACKAGE_WIFI_AP=y BR2_PACKAGE_ALSA_PLUGINS=y BR2_PACKAGE_BTSPEAKER=y BR2_PACKAGE_FANN=y +BR2_PACKAGE_HOSTNAME_SERVICE=y BR2_PACKAGE_MYCROFT_MPD=y BR2_PACKAGE_RESPEAKER=y BR2_PACKAGE_SNAPCAST=y diff --git a/buildroot-external/package/hostname-service/Config.in b/buildroot-external/package/hostname-service/Config.in new file mode 100644 index 00000000..27ab9242 --- /dev/null +++ b/buildroot-external/package/hostname-service/Config.in @@ -0,0 +1,5 @@ +config BR2_PACKAGE_HOSTNAME_SERVICE + bool "hostname-service" + help + A systemd service that adds the last bits + of the MAC address to the hostname. diff --git a/buildroot-external/package/hostname-service/hostname-service.mk b/buildroot-external/package/hostname-service/hostname-service.mk new file mode 100644 index 00000000..1e2a6db6 --- /dev/null +++ b/buildroot-external/package/hostname-service/hostname-service.mk @@ -0,0 +1,21 @@ +################################################################################ +# +# hostname-service +# +################################################################################ + +HOSTNAME_SERVICE_VERSION = 0.1.0 +HOSTNAME_SERVICE_SITE = $(BR2_EXTERNAL_MYCROFTOS_PATH)/package/hostname-service +HOSTNAME_SERVICE_SITE_METHOD = local +HOSTNAME_SERVICE_LICENSE = Apache License 2.0 +HOSTNAME_SERVICE_LICENSE_FILES = LICENSE + +define HOSTNAME_SERVICE_INSTALL_TARGET_CMDS + $(INSTALL) -D -m 644 $(@D)/hostname.service \ + $(TARGET_DIR)/usr/lib/systemd/system/hostname.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -fs ../../../../usr/lib/systemd/system/hostname.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/hostname.service +endef + +$(eval $(generic-package)) diff --git a/buildroot-external/package/hostname-service/hostname.service b/buildroot-external/package/hostname-service/hostname.service new file mode 100644 index 00000000..4b372b93 --- /dev/null +++ b/buildroot-external/package/hostname-service/hostname.service @@ -0,0 +1,11 @@ +[Unit] +Description=Set hostname to MycroftOS-[MAC] +Before=systemd-networkd.service +Before=avahi-daemon.service + +[Service] +Type=oneshot +ExecStart=/bin/sh -c "hostnamectl set-hostname MycroftOS-`sed 's/://g' /sys/class/net/eth0/address | tail -c 7`" + +[Install] +WantedBy=multi-user.target