For macOS 11.x (Big Sur)
#!/bin/bash
# https://en.tab-tv.com/?p=18929
# https://github.com/MagerValp/MacModelShelf/blob/master/dump.markdown (Apple Serial Number Product Code)
# https://mrmacintosh.com/list-of-mac-boardid-deviceid-model-identifiers-machine-models/
# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
# JG5H MacBook Pro (15-inch, 2018)
# JG5L MacBook Pro (15-inch, 2018)
# JG5M MacBook Pro (15-inch, 2018)
# JGH5 MacBook Pro (15-inch, 2018)
# JGH6 MacBook Pro (15-inch, 2018)
# JGH7 MacBook Pro (15-inch, 2018)
# JGH8 MacBook Pro (15-inch, 2018)
sBoardId=Mac-937A206F2EE63C01
sProductCode=JG5M
GetVMDetails() {
sKey="$("${VB}" getextradata "${sVMName}" | tr -d '\r')"
sBP="$(echo "${sKey}" | grep DmiBoardProduct | sed 's/^.*Value: //')"
sSP="$(echo "${sKey}" | grep DmiSystemProduct | sed 's/^.*Value: //')"
sSS="$(echo "${sKey}" | grep DmiSystemSerial | sed 's/^.*Value: //')"
}
if [[ "$(uname -r)" == *Microsoft ]]; then
VB="/mnt/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
elif [[ "$(uname -s)" == Darwin ]]; then
VB="/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
elif [[ "$(uname -a)" == *Cygwin* ]]; then
VB="/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
else
VB=""
fi
[[ -z "${VB}" || ! -e "${VB}" ]] && exit
sValidDigit="0123456789BCDFGHJKLMNPQRTVWXYX"
nSeq=0
"${VB}" list -s vms | grep "Mac OS X 11." | cut -d\" -f2 | sort | while read sVMName; do
echo "${sVMName}"
GetVMDetails
printf ' Current => %-35s : %-25s : %s : %s\n' "${sVMName}" "${sBP}" "${sSP}" "${sSS}"
nSeq=$((nSeq + 1))
# iBridge2,3 J680AP 0x0B Apple T2 MacBookPro15,1 (j680)
# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
sSequantial="1Q${sValidDigit:${nSeq}:1}"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro15,1"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "${sBoardId}"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial" "C02XH${sSequantial}${sProductCode}"
# C02 -> Factory/Line number
# XH -> 2018/October
GetVMDetails
printf ' New => %-35s : %-25s : %s : %s\n' "${sVMName}" "${sBP}" "${sSP}" "${sSS}"
done
# https://en.tab-tv.com/?p=18929
# https://github.com/MagerValp/MacModelShelf/blob/master/dump.markdown (Apple Serial Number Product Code)
# https://mrmacintosh.com/list-of-mac-boardid-deviceid-model-identifiers-machine-models/
# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
# JG5H MacBook Pro (15-inch, 2018)
# JG5L MacBook Pro (15-inch, 2018)
# JG5M MacBook Pro (15-inch, 2018)
# JGH5 MacBook Pro (15-inch, 2018)
# JGH6 MacBook Pro (15-inch, 2018)
# JGH7 MacBook Pro (15-inch, 2018)
# JGH8 MacBook Pro (15-inch, 2018)
sBoardId=Mac-937A206F2EE63C01
sProductCode=JG5M
GetVMDetails() {
sKey="$("${VB}" getextradata "${sVMName}" | tr -d '\r')"
sBP="$(echo "${sKey}" | grep DmiBoardProduct | sed 's/^.*Value: //')"
sSP="$(echo "${sKey}" | grep DmiSystemProduct | sed 's/^.*Value: //')"
sSS="$(echo "${sKey}" | grep DmiSystemSerial | sed 's/^.*Value: //')"
}
if [[ "$(uname -r)" == *Microsoft ]]; then
VB="/mnt/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
elif [[ "$(uname -s)" == Darwin ]]; then
VB="/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
elif [[ "$(uname -a)" == *Cygwin* ]]; then
VB="/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
else
VB=""
fi
[[ -z "${VB}" || ! -e "${VB}" ]] && exit
sValidDigit="0123456789BCDFGHJKLMNPQRTVWXYX"
nSeq=0
"${VB}" list -s vms | grep "Mac OS X 11." | cut -d\" -f2 | sort | while read sVMName; do
echo "${sVMName}"
GetVMDetails
printf ' Current => %-35s : %-25s : %s : %s\n' "${sVMName}" "${sBP}" "${sSP}" "${sSS}"
nSeq=$((nSeq + 1))
# iBridge2,3 J680AP 0x0B Apple T2 MacBookPro15,1 (j680)
# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
sSequantial="1Q${sValidDigit:${nSeq}:1}"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro15,1"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "${sBoardId}"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial" "C02XH${sSequantial}${sProductCode}"
# C02 -> Factory/Line number
# XH -> 2018/October
GetVMDetails
printf ' New => %-35s : %-25s : %s : %s\n' "${sVMName}" "${sBP}" "${sSP}" "${sSS}"
done
For macOS 12 (Monterey)
#!/bin/bash
# https://en.tab-tv.com/?p=18929
# https://github.com/MagerValp/MacModelShelf/blob/master/dump.markdown (Apple Serial Number Product Code)
# https://mrmacintosh.com/list-of-mac-boardid-deviceid-model-identifiers-machine-models/
# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
# JG5H MacBook Pro (15-inch, 2018)
# JG5L MacBook Pro (15-inch, 2018)
# JG5M MacBook Pro (15-inch, 2018)
# JGH5 MacBook Pro (15-inch, 2018)
# JGH6 MacBook Pro (15-inch, 2018)
# JGH7 MacBook Pro (15-inch, 2018)
# JGH8 MacBook Pro (15-inch, 2018)
sBoardId=Mac-937A206F2EE63C01
sProductCode=JG5M
GetVMDetails() {
sKey="$("${VB}" getextradata "${sVMName}" | tr -d '\r')"
sBP="$(echo "${sKey}" | grep DmiBoardProduct | sed 's/^.*Value: //')"
sSP="$(echo "${sKey}" | grep DmiSystemProduct | sed 's/^.*Value: //')"
sSS="$(echo "${sKey}" | grep DmiSystemSerial | sed 's/^.*Value: //')"
}
if [[ "$(uname -r)" == *Microsoft ]]; then
VB="/mnt/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
elif [[ "$(uname -s)" == Darwin ]]; then
VB="/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
elif [[ "$(uname -a)" == *Cygwin* ]]; then
VB="/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
else
VB=""
fi
[[ -z "${VB}" || ! -e "${VB}" ]] && exit
sValidDigit="0123456789BCDFGHJKLMNPQRTVWXYX"
nSeq=0
"${VB}" list -s vms | grep "Mac OS X 12." | cut -d\" -f2 | sort | while read sVMName; do
echo "${sVMName}"
GetVMDetails
printf ' Current => %-35s : %-25s : %s : %s\n' "${sVMName}" "${sBP}" "${sSP}" "${sSS}"
nSeq=$((nSeq + 1))
# iBridge2,3 J680AP 0x0B Apple T2 MacBookPro15,1 (j680)
# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
sSequantial="1Q${sValidDigit:${nSeq}:1}"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro15,1"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "${sBoardId}"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial" "C02XH${sSequantial}${sProductCode}"
# C02 -> Factory/Line number
# XH -> 2018/October
GetVMDetails
printf ' New => %-35s : %-25s : %s : %s\n' "${sVMName}" "${sBP}" "${sSP}" "${sSS}"
done
# https://en.tab-tv.com/?p=18929
# https://github.com/MagerValp/MacModelShelf/blob/master/dump.markdown (Apple Serial Number Product Code)
# https://mrmacintosh.com/list-of-mac-boardid-deviceid-model-identifiers-machine-models/
# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
# JG5H MacBook Pro (15-inch, 2018)
# JG5L MacBook Pro (15-inch, 2018)
# JG5M MacBook Pro (15-inch, 2018)
# JGH5 MacBook Pro (15-inch, 2018)
# JGH6 MacBook Pro (15-inch, 2018)
# JGH7 MacBook Pro (15-inch, 2018)
# JGH8 MacBook Pro (15-inch, 2018)
sBoardId=Mac-937A206F2EE63C01
sProductCode=JG5M
GetVMDetails() {
sKey="$("${VB}" getextradata "${sVMName}" | tr -d '\r')"
sBP="$(echo "${sKey}" | grep DmiBoardProduct | sed 's/^.*Value: //')"
sSP="$(echo "${sKey}" | grep DmiSystemProduct | sed 's/^.*Value: //')"
sSS="$(echo "${sKey}" | grep DmiSystemSerial | sed 's/^.*Value: //')"
}
if [[ "$(uname -r)" == *Microsoft ]]; then
VB="/mnt/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
elif [[ "$(uname -s)" == Darwin ]]; then
VB="/Applications/VirtualBox.app/Contents/MacOS/VBoxManage"
elif [[ "$(uname -a)" == *Cygwin* ]]; then
VB="/cygdrive/c/Program Files/Oracle/VirtualBox/VBoxManage.exe"
else
VB=""
fi
[[ -z "${VB}" || ! -e "${VB}" ]] && exit
sValidDigit="0123456789BCDFGHJKLMNPQRTVWXYX"
nSeq=0
"${VB}" list -s vms | grep "Mac OS X 12." | cut -d\" -f2 | sort | while read sVMName; do
echo "${sVMName}"
GetVMDetails
printf ' Current => %-35s : %-25s : %s : %s\n' "${sVMName}" "${sBP}" "${sSP}" "${sSS}"
nSeq=$((nSeq + 1))
# iBridge2,3 J680AP 0x0B Apple T2 MacBookPro15,1 (j680)
# MacBookPro15,1 (15-inch Mid 2018) Mac-937A206F2EE63C01
sSequantial="1Q${sValidDigit:${nSeq}:1}"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemProduct" "MacBookPro15,1"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiBoardProduct" "${sBoardId}"
"${VB}" setextradata "${sVMName}" "VBoxInternal/Devices/efi/0/Config/DmiSystemSerial" "C02XH${sSequantial}${sProductCode}"
# C02 -> Factory/Line number
# XH -> 2018/October
GetVMDetails
printf ' New => %-35s : %-25s : %s : %s\n' "${sVMName}" "${sBP}" "${sSP}" "${sSS}"
done
Comments
Post a Comment