arv-v-dsm/serial.sh

40 lines
1.2 KiB
Bash
Raw Normal View History

2023-03-28 11:45:24 +07:00
#!/bin/bash
2023-04-14 05:56:45 +07:00
set -eu
2023-03-28 11:45:24 +07:00
2023-04-08 06:15:41 +07:00
# Docker environment variabeles
2023-04-14 20:17:24 +07:00
: ${HOST_CPU:=''}
2023-04-14 05:56:45 +07:00
: ${HOST_BUILD:='42962'}
: ${HOST_VERSION:='2.6.1-12139'}
: ${HOST_TIMESTAMP:='1679863686'}
: ${HOST_SERIAL:='0000000000000'}
: ${GUEST_SERIAL:='0000000000000'}
: ${GUEST_UUID:='ba13a19a-c0c1-4fef-9346-915ed3b98341'}
2023-04-03 02:38:34 +07:00
2023-04-14 20:17:24 +07:00
if [ -z "$HOST_CPU" ]; then
HOST_CPU=$(lscpu | sed -nr '/Model name/ s/.*:\s*(.*) @ .*/\1/p' | sed ':a;s/ / /;ta' | sed s/"(R)"//g | sed s/"-"//g | sed 's/[^[:alnum:] ]\+//g')
fi
2023-04-08 07:22:28 +07:00
2023-04-14 20:17:24 +07:00
if [ -n "$HOST_CPU" ]; then
HOST_CPU="$HOST_CPU,,"
2023-04-08 07:22:28 +07:00
else
2023-04-14 20:17:24 +07:00
HOST_CPU="QEMU, Virtual CPU, X86_64"
2023-04-08 07:22:28 +07:00
fi
2023-04-08 06:30:25 +07:00
2023-04-08 07:00:29 +07:00
./run/serial.bin -cpu="${CPU_CORES}" \
2023-04-14 20:17:24 +07:00
-cpu_arch="${HOST_CPU}" \
2023-04-14 05:56:45 +07:00
-hostsn="${HOST_SERIAL}" \
-guestsn="${GUEST_SERIAL}" \
-vmmts="${HOST_TIMESTAMP}" \
-vmmversion="${HOST_VERSION}" \
-buildnumber="${HOST_BUILD}" \
-guestuuid="${GUEST_UUID}" > /dev/null 2>&1 &
2023-04-03 02:38:34 +07:00
KVM_SERIAL_OPTS="\
2023-04-14 05:56:45 +07:00
-serial mon:stdio \
-device virtio-serial-pci,id=virtio-serial0,bus=pcie.0,addr=0x3 \
-chardev pty,id=charserial0 \
-device isa-serial,chardev=charserial0,id=serial0 \
-chardev socket,id=charchannel0,host=127.0.0.1,port=12345,reconnect=10 \
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=vchannel"