diff options
author | P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com> | 2022-03-31 00:20:48 +0300 |
---|---|---|
committer | P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com> | 2022-05-06 02:21:19 +0300 |
commit | 18f97faa411078b95d042d207f5fff32bc8ece1d (patch) | |
tree | c557da2136640a8ce48439f19fe5f7071faffeca /meta-openbmc-mods/meta-common/recipes-network/network/static-mac-addr/mac-check | |
parent | 2af35ee50ce9918ee3626c59f2cff62cd3ab9568 (diff) | |
download | openbmc-18f97faa411078b95d042d207f5fff32bc8ece1d.tar.xz |
Update to internal 1-0.91
Signed-off-by: P Dheeraj Srujan Kumar <p.dheeraj.srujan.kumar@intel.com>
Diffstat (limited to 'meta-openbmc-mods/meta-common/recipes-network/network/static-mac-addr/mac-check')
-rw-r--r-- | meta-openbmc-mods/meta-common/recipes-network/network/static-mac-addr/mac-check | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/meta-openbmc-mods/meta-common/recipes-network/network/static-mac-addr/mac-check b/meta-openbmc-mods/meta-common/recipes-network/network/static-mac-addr/mac-check index 39d7dd8a7..429f9264b 100644 --- a/meta-openbmc-mods/meta-common/recipes-network/network/static-mac-addr/mac-check +++ b/meta-openbmc-mods/meta-common/recipes-network/network/static-mac-addr/mac-check @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # Copyright 2018 Intel Corporation # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -158,4 +158,29 @@ done <<-END_CONF eth0 eth1addr eth1 ethaddr END_CONF + +### HOSTNAME FEATURE ### +if [[ $* == *--no-unique-hostname* ]]; then + echo "mac-check: Skipping hostname check" +else + # Read MAC and strip colon chars + hw_mac=$(cat /sys/class/net/eth0/address | tr -d ":") + # Read Hostname + hostname=$(hostname) + #Match bmc-mac<any MAC address> (a MAC address has 12 hex digits) + bmc_mac_format="^bmc-mac[a-f0-9]{12}$" + #Match bmc-mac<current MAC address> + inteldefault="bmc-mac$hw_mac" + #if the current hostname already has the current MAC address, we won't rewrite the name unnecessarily. + #Otherwise, match intel-obmc or bmc-mac<any MAC address>, and change the hostname to use the current MAC address + if [[ "$hostname" == "intel-obmc" || \ + ("$hostname" != "$inteldefault" && \ + "$hostname" =~ $bmc_mac_format) ]]; then + hostnamectl set-hostname "$inteldefault" + echo "mac-check: HOSTNAME CHANGED (hostname deemed to be default or wrong MAC Address)" + else + echo "mac-check: HOSTNAME NOT CHANGED (hostname is already correct or is custom)" + fi +fi + exit $first_error_seen |