summaryrefslogtreecommitdiff
path: root/recipes-core/set-hostname/files/set-hostname.service
diff options
context:
space:
mode:
authorLuka Pivk <luka.pivk@toradex.com>2020-03-06 16:01:52 +0100
committerLuka Pivk <luka.pivk@toradex.com>2020-03-18 16:46:54 +0100
commitb1b000a591963ed7103be0cbe468a1b0c5549f9f (patch)
treeb4d08d7c424bb537188e032daa602a56a928300c /recipes-core/set-hostname/files/set-hostname.service
parent2d38b92941737400dc5b6279548b85483d3026c4 (diff)
hostname: generate a uniqe hostname on boot
This will generate a hostname based on machine name and serial number. (E.g. colibri-imx7-031111777) If serial number is not found it will say "no-serial-number" in host name. If machine is not supported hostname will include "unsupported-device" string. If /dev/device-tree does not exist it will say "recovery-mode" as it assumes its in recovery mode of Toradex Easy Installer To prevent openembedded from creating /etc/hostname file add hostname_pn-base-files = "" to configration Related-to: TEI-100, ELB-1322 Signed-off-by: Luka Pivk <luka.pivk@toradex.com>
Diffstat (limited to 'recipes-core/set-hostname/files/set-hostname.service')
-rw-r--r--recipes-core/set-hostname/files/set-hostname.service13
1 files changed, 13 insertions, 0 deletions
diff --git a/recipes-core/set-hostname/files/set-hostname.service b/recipes-core/set-hostname/files/set-hostname.service
new file mode 100644
index 0000000..306528b
--- /dev/null
+++ b/recipes-core/set-hostname/files/set-hostname.service
@@ -0,0 +1,13 @@
+[Unit]
+ConditionPathExists=|!/etc/hostname
+Wants=network-pre.target
+Before=network-pre.target
+After=local-fs.target
+After=sys-subsystem-net-devices-eth0.device
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/sethostname
+
+[Install]
+WantedBy=network.target