#!/bin/bash

function hash_mac {
mac="$1"
key="8544e3b47eca58f9583043f8"
sub="\x"

#convert mac to hex
hexmac="\x${mac//:/$sub}"

#create hash
code=$(printf "$hexmac" | openssl dgst -sha1 -mac HMAC -macopt hexkey:"$key")

#DEBUG
#echo "$mac"
#echo "$hexmac"
#echo "$code"
echo "${code:9:4}-${code:13:4}-${code:17:4}-${code:21:4}-${code:25:4}-${code:29:4}"
}

MAC=$( ipmitool lan print | grep "MAC Address" | awk ‘{print $4}’ )

hex output with input
KEY=$(hash_mac "$MAC")

./sum -c ActivateProductKey –key $KEY