From a30ec01ac438fb4524e987f207de767c29b1e74d Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Wed, 26 Oct 2016 13:32:40 +0200 Subject: add prefix to hostname --- hook/hostname | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hook/hostname b/hook/hostname index e37e90c..a95d428 100644 --- a/hook/hostname +++ b/hook/hostname @@ -5,6 +5,8 @@ run_latehook() { /usr/bin/systemd-machine-id-setup --root="${newroot}" + hostprefix="$(cat "${newroot}/etc/hostname")" + if [[ -n "${hostname}" ]]; then msg ":: Setting hostname for main system to '${hostname}'..." elif [[ -e /sys/class/dmi/id/product_uuid ]]; then @@ -15,6 +17,6 @@ run_latehook() { hostname="$(cut -d- -f1 < /proc/sys/kernel/random/boot_id)" fi - echo -n "${hostname}" > "${newroot}/etc/hostname" - sed -i "/^127.0.0.1/s/$/\t${hostname}/" "${newroot}/etc/hosts" + echo -n "${hostprefix}-${hostname}" > "${newroot}/etc/hostname" + sed -i "/^127.0.0.1/s/$/\t${hostprefix}-${hostname}/" "${newroot}/etc/hosts" } -- cgit v1.2.3-70-g09d2