hostname: Generate a unique hostname once This picks a random adjective-noun combination using two wordlists of 26 words each, giving us a random domain of 676 possible human-readable names to refer to our boards with. Change-Id: If7c3ff814fa4321322e42c7afa999cc28c467b2c
diff --git a/etc/runonce.d/01-generate-hostname b/etc/runonce.d/01-generate-hostname new file mode 100755 index 0000000..e0a6516 --- /dev/null +++ b/etc/runonce.d/01-generate-hostname
@@ -0,0 +1,22 @@ +#!/bin/bash + +random_word() +{ + local wordlist=$1; shift + local max=$(wc -l $wordlist |awk '{ print $1 }') + local line=$(($RANDOM % $max + 1)) + + head -n $line $wordlist |tail -n 1 +} + +generate_hostname() +{ + local adj=$(random_word /tmp/adjectives.txt) + local noun=$(random_word /tmp/nouns.txt) + + echo "${adj}-${noun}" +} + +hostname=$(generate_hostname) +echo $hostname >/etc/hostname +/usr/bin/hostnamectl set-hostname $hostname
diff --git a/etc/runonce.d/01-enable-services b/etc/runonce.d/02-enable-services similarity index 100% rename from etc/runonce.d/01-enable-services rename to etc/runonce.d/02-enable-services
diff --git a/etc/runonce.d/02-check-ssh-keys b/etc/runonce.d/03-check-ssh-keys similarity index 100% rename from etc/runonce.d/02-check-ssh-keys rename to etc/runonce.d/03-check-ssh-keys
diff --git a/etc/services/mdt.service b/etc/services/mdt.service new file mode 100644 index 0000000..99c50eb --- /dev/null +++ b/etc/services/mdt.service
@@ -0,0 +1,8 @@ +<service-group> + <name replace-wildcards="yes">%h</name> + + <service> + <type>_google._mdt._tcp</type> + <port>22</port> + </service> +</service-group>
diff --git a/usr/share/aiy-board-tweaks/adjectives.txt b/usr/share/aiy-board-tweaks/adjectives.txt new file mode 100644 index 0000000..49a4c93 --- /dev/null +++ b/usr/share/aiy-board-tweaks/adjectives.txt
@@ -0,0 +1,26 @@ +arid +bored +coy +deft +elusive +fun +green +hopeful +indigo +jumping +king +lime +mocha +neat +orange +purple +queen +red +silly +tuned +undefined +vexing +wishful +xenial +yellow +zippy
diff --git a/usr/share/aiy-board-tweaks/nouns.txt b/usr/share/aiy-board-tweaks/nouns.txt new file mode 100644 index 0000000..b55eec0 --- /dev/null +++ b/usr/share/aiy-board-tweaks/nouns.txt
@@ -0,0 +1,26 @@ +apple +bunny +calf +dog +eft +finch +goose +horse +ibis +jet +kid +llama +mole +nexus +orange +pig +quill +rabbit +snail +tang +umpire +valet +wasp +xylophone +yarn +zebra