aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2016-10-26 13:32:40 +0200
committerGravatar Christian Hesse <mail@eworm.de>2016-10-26 13:32:40 +0200
commita30ec01ac438fb4524e987f207de767c29b1e74d (patch)
tree778de7c4a93a83109ae0eda2b94607c0eddc4f50
parentd99bba29041932df7caeabd895f4eb5a95afa12c (diff)
downloadmkinitcpio-hostname-a30ec01ac438fb4524e987f207de767c29b1e74d.tar.gz
mkinitcpio-hostname-a30ec01ac438fb4524e987f207de767c29b1e74d.tar.zst
add prefix to hostname
-rw-r--r--hook/hostname6
1 files 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"
}