From f4acbd06fd8dbfb52b8d3f4b0b93be04a1130af7 Mon Sep 17 00:00:00 2001 From: Christian Hesse Date: Mon, 27 May 2013 11:44:04 +0200 Subject: Initial import --- hook/hostname | 17 +++++++++++++++++ install/hostname | 9 +++++++++ 2 files changed, 26 insertions(+) create mode 100644 hook/hostname create mode 100644 install/hostname diff --git a/hook/hostname b/hook/hostname new file mode 100644 index 0000000..6421987 --- /dev/null +++ b/hook/hostname @@ -0,0 +1,17 @@ +#!/bin/sh + +run_latehook() { + local newroot="/new_root/" + 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)" + else + msg ":: Setting hostname to random string..." + 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" +} diff --git a/install/hostname b/install/hostname new file mode 100644 index 0000000..7f41a4d --- /dev/null +++ b/install/hostname @@ -0,0 +1,9 @@ +#!/bin/sh + +build() { + add_runscript +} + +help() { + echo "This hook changes system hostname from inside initramfs." +} -- cgit v1.2.3-54-g00ecf