summaryrefslogtreecommitdiffstats
path: root/hook/hostname
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2015-06-29 16:14:03 +0200
committerGravatar Christian Hesse <mail@eworm.de>2015-06-29 16:14:03 +0200
commitd99bba29041932df7caeabd895f4eb5a95afa12c (patch)
tree982c0bacc57a62bdfa7282bf5a79c982fad788c1 /hook/hostname
parent375a632d83192f0fcd0a8c7a8b9b9ddc44b0a15e (diff)
downloadmkinitcpio-hostname-d99bba29041932df7caeabd895f4eb5a95afa12c.tar.gz
mkinitcpio-hostname-d99bba29041932df7caeabd895f4eb5a95afa12c.tar.zst
calculate hash from product id
Some similar devices share big identical parts of product id... So calculate a hash and cut.
Diffstat (limited to 'hook/hostname')
-rw-r--r--hook/hostname4
1 files changed, 2 insertions, 2 deletions
diff --git a/hook/hostname b/hook/hostname
index 07c8be6..e37e90c 100644
--- a/hook/hostname
+++ b/hook/hostname
@@ -8,8 +8,8 @@ run_latehook() {
if [[ -n "${hostname}" ]]; then
msg ":: Setting hostname for main system to '${hostname}'..."
elif [[ -e /sys/class/dmi/id/product_uuid ]]; then
- msg ":: Setting hostname to first bits of product uuid..."
- hostname="$(cut -d- -f1 < /sys/class/dmi/id/product_uuid)"
+ msg ":: Setting hostname from product uuid..."
+ hostname="$(sha1sum < /sys/class/dmi/id/product_uuid | cut -c1-8)"
else
msg ":: Setting hostname to random string..."
hostname="$(cut -d- -f1 < /proc/sys/kernel/random/boot_id)"