virtual-dsm/serial.sh

37 lines
1.1 KiB
Bash
Raw Normal View History

2023-03-28 06:45:24 +02:00
#!/bin/bash
2023-04-14 00:56:45 +02:00
set -eu
2023-03-28 06:45:24 +02:00
2023-04-08 01:15:41 +02:00
# Docker environment variabeles
2023-04-14 00:56:45 +02: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-02 21:38:34 +02:00
2023-04-08 02:15:15 +02:00
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')
2023-04-08 02:22:28 +02:00
2023-04-08 02:24:10 +02:00
if [ -n "$CPU" ]; then
2023-04-08 02:22:28 +02:00
CPU="$CPU,,"
else
CPU="QEMU, Virtual CPU, X86_64"
fi
2023-04-08 01:30:25 +02:00
2023-04-08 02:00:29 +02:00
./run/serial.bin -cpu="${CPU_CORES}" \
2023-04-14 00:56:45 +02:00
-cpu_arch="${CPU}" \
-hostsn="${HOST_SERIAL}" \
-guestsn="${GUEST_SERIAL}" \
-vmmts="${HOST_TIMESTAMP}" \
-vmmversion="${HOST_VERSION}" \
-buildnumber="${HOST_BUILD}" \
-guestuuid="${GUEST_UUID}" > /dev/null 2>&1 &
2023-04-02 21:38:34 +02:00
KVM_SERIAL_OPTS="\
2023-04-14 00:56:45 +02: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"