fix: CPU configuration

This commit is contained in:
Kroese 2023-12-16 05:08:34 +01:00 committed by GitHub
parent 970a662170
commit 32748509ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,9 +1,14 @@
#!/bin/bash
set -Eeuo pipefail
# Docker environment variables
: ${HOST_CPU:=''}
: ${CPU_MODEL:='host'}
: ${QEMU_CPU:='qemu64,+ssse3,+sse4,+sse4.1,+sse4.2'}
KVM_ERR=""
KVM_OPTS=""
QEMU_CPU="qemu64,+ssse3,+sse4,+sse4.1,+sse4.2"
if [ "$ARCH" == "amd64" ] && [[ "$KVM" != [Nn]* ]]; then
@ -37,4 +42,23 @@ else
fi
if [ -z "$HOST_CPU" ] && [ "$CPU_MODEL" == "host"* ]; then
HOST_CPU=$(lscpu | grep 'Model name' | cut -f 2 -d ":" | awk '{$1=$1}1' | sed 's# @.*##g' | sed s/"(R)"//g | sed 's/[^[:alnum:] ]\+/ /g' | sed 's/ */ /g')
fi
if [ -n "$HOST_CPU" ]; then
HOST_CPU="${HOST_CPU%%,*},,"
else
if [ "$CPU_MODEL" == "host"* ] || [ "$CPU_MODEL" == "qemu"* ]; then
HOST_CPU="QEMU"
else
HOST_CPU="${CPU_MODEL%%,*}"
fi
if [ "$ARCH" == "amd64" ]; then
HOST_CPU="${HOST_CPU%%,*}, Virtual CPU, X86_64"
else
HOST_CPU="${HOST_CPU%%,*}, Virtual CPU, $ARCH"
fi
fi
return 0