diff options
author | jmbills <jason.m.bills@intel.com> | 2022-01-18 21:55:05 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-18 21:55:05 +0300 |
commit | 7cf0c1cd0ce835d1833509b7b911e8a97380278b (patch) | |
tree | 0b45c3beaa9874facc4ed1a2395a31e42be0135d /meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh | |
parent | 4dac5fcd49b5e2de1074f1363775ec0f19041072 (diff) | |
parent | 1fc0d70f658da30091bcd49f9bf29aecd6b99ba7 (diff) | |
download | openbmc-7cf0c1cd0ce835d1833509b7b911e8a97380278b.tar.xz |
Merge pull request #76 from Intel-BMC/update1-0.86
Update
Diffstat (limited to 'meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh')
-rw-r--r-- | meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh index 4e4d6f3e7..8182b4c8d 100644 --- a/meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh +++ b/meta-ampere/meta-jade/recipes-ampere/platform/ampere-mac-update/ampere_update_mac.sh @@ -5,43 +5,44 @@ ETHERNET_INTERFACE="eth1" ETHERNET_NCSI="eth0" ENV_ETH="eth1addr" -ENV_MAC_ADDR=`fw_printenv | grep $ENV_ETH` +ENV_MAC_ADDR=$(fw_printenv | grep $ENV_ETH) # Workaround to dhcp NC-SI eth0 interface when BMC boot up ifconfig ${ETHERNET_NCSI} down ifconfig ${ETHERNET_NCSI} up # Read FRU Board Custom Field 1 to get the MAC address -CUSTOM_FIELD_1=`busctl get-property xyz.openbmc_project.FruDevice /xyz/openbmc_project/FruDevice/Mt_Jade_Motherboard xyz.openbmc_project.FruDevice BOARD_INFO_AM1` -MAC_ADDR=`echo $CUSTOM_FIELD_1 | cut -d "\"" -f 2` +CUSTOM_FIELD_1=$(busctl get-property xyz.openbmc_project.FruDevice /xyz/openbmc_project/FruDevice/Mt_Jade_Motherboard xyz.openbmc_project.FruDevice BOARD_INFO_AM1) +MAC_ADDR=$(echo "$CUSTOM_FIELD_1" | cut -d "\"" -f 2) # Check if BMC MAC address is exported if [ -z "${MAC_ADDR}" ]; then - echo "ERROR: No BMC MAC address is detected from FRU Inventory information!" - # Return 1 so that systemd knows the service failed to start - exit 1 + echo "ERROR: No BMC MAC address is detected from FRU Inventory information!" + # Return 1 so that systemd knows the service failed to start + exit 1 fi # Check if BMC MAC address is exported if [[ $ENV_MAC_ADDR =~ $MAC_ADDR ]]; then - echo "WARNING: BMC MAC address already exist!" - exit 0 + echo "WARNING: BMC MAC address already exist!" + exit 0 fi # Request to update the MAC address -fw_setenv ${ENV_ETH} ${MAC_ADDR} +fw_setenv ${ENV_ETH} "${MAC_ADDR}" -if [[ $? -ne 0 ]]; then - echo "ERROR: Fail to set MAC address to ${ENV_ETH}" - exit 1 +if fw_setenv ${ENV_ETH} "${MAC_ADDR}"; +then + echo "ERROR: Fail to set MAC address to ${ENV_ETH}" + exit 1 fi # Request to restart the service ifconfig ${ETHERNET_INTERFACE} down -ifconfig ${ETHERNET_INTERFACE} hw ether ${MAC_ADDR} -if [[ $? -ne 0 ]]; then - echo "ERROR: Can not update MAC ADDR to ${ETHERNET_INTERFACE}" - exit 1 +if ! ifconfig ${ETHERNET_INTERFACE} hw ether "${MAC_ADDR}"; +then + echo "ERROR: Can not update MAC ADDR to ${ETHERNET_INTERFACE}" + exit 1 fi ifconfig ${ETHERNET_INTERFACE} up |