diff options
author | Eric Hameleers <alien@slackware.com> | 2016-05-05 16:01:17 +0200 |
---|---|---|
committer | Eric Hameleers <alien@slackware.com> | 2016-05-05 16:01:17 +0200 |
commit | 7b6180eee2d9428de12ce1453c32a00d79449026 (patch) | |
tree | 4c8bf74dfbb660973257b68d009bb1a56689dec0 | |
parent | c928e54aa12040290b5facd9f0667c9b5624586d (diff) | |
download | liveslak-7b6180eee2d9428de12ce1453c32a00d79449026.tar.gz liveslak-7b6180eee2d9428de12ce1453c32a00d79449026.tar.xz |
liveinit: when network-booting, add MAC address as suffix to the hostname.
This default behaviour can be prohibited by applying an extended 'hostname'
boot parameter as follows:
hostname=your_custom_hostname,fixed
The qualifier 'fixed' after the comma will prevent the hostname from being
changed to something else than 'your_custom_hostname'.
-rwxr-xr-x | liveinit | 21 |
1 files changed, 20 insertions, 1 deletions
@@ -72,6 +72,8 @@ BLACKLIST="" GLAMORACCEL=1 # NFS root support: +HNMAC="" +HNMAC_ALLOWED="YES" INTERFACE="" NFSHOST="" @@ -116,7 +118,12 @@ for ARG in $(cat /proc/cmdline); do DHCPWAIT=$(echo $ARG | cut -f2 -d=) ;; hostname=*) - LIVE_HOSTNAME=$(echo $ARG | cut -f2 -d=) + # generic syntax: hostname=newname[,qualifier] + LIVE_HOSTNAME=$(echo $ARG | cut -f2 -d= | cut -f1 -d,) + if [ "$(echo $ARG | cut -f2 -d= | cut -f2 -d,)" = "fixed" ]; then + Keep hostname fixed i.e. never add a MAC address suffix: + HNMAC_ALLOWED="NO" + fi ;; init=*) INIT=$(echo $ARG | cut -f2 -d=) @@ -411,6 +418,9 @@ if [ "$RESCUE" = "" ]; then fi fi + # Store the interface MAC address so we may modify the hostname with it: + HNMAC=$(ip link show ${INTERFACE} |grep link/ether |tr -s ' ' |cut -d ' ' -f3 |tr -d ':') + } # End setnet() find_loop() { @@ -842,6 +852,15 @@ root:${ROOTPW} EOPW fi + if [ ! -z "$HNMAC" -a "$HNMAC_ALLOWED" = "YES" ]; then + # We are booting from the network, give it a unique hostname: + if [ -z "$LIVE_HOSTNAME" ]; then + LIVE_HOSTNAME="@DARKSTAR@-${HNMAC}" + else + LIVE_HOSTNAME="${LIVE_HOSTNAME}-${HNMAC}" + fi + fi + if [ ! -z "$LIVE_HOSTNAME" ]; then # User entered a custom hostname on the boot commandline: echo "${MARKER}: Changing hostname to '$LIVE_HOSTNAME'." |