mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-07 00:48:23 +08:00
Added environment variabeles
This commit is contained in:
parent
b800a91ad0
commit
65a5a654ea
59
serial.sh
59
serial.sh
@ -1,33 +1,14 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
set -eu
|
||||||
|
|
||||||
# Docker environment variabeles
|
# Docker environment variabeles
|
||||||
: ${HOST_SERIAL:=''}
|
|
||||||
: ${GUEST_SERIAL:=''}
|
|
||||||
|
|
||||||
permanent="DSM"
|
: ${HOST_BUILD:='42962'}
|
||||||
serialstart="2000"
|
: ${HOST_VERSION:='2.6.1-12139'}
|
||||||
|
: ${HOST_TIMESTAMP:='1679863686'}
|
||||||
[ ! -d "$IMG" ] && echo "Storage folder (${IMG}) not found!" && exit 69
|
: ${HOST_SERIAL:='0000000000000'}
|
||||||
|
: ${GUEST_SERIAL:='0000000000000'}
|
||||||
#If environment variabele not set fall back to file
|
: ${GUEST_UUID:='ba13a19a-c0c1-4fef-9346-915ed3b98341'}
|
||||||
if [ -z "$HOST_SERIAL" ]; then
|
|
||||||
FILE="${IMG}/host.serial"
|
|
||||||
if [ ! -f "$FILE" ]; then
|
|
||||||
SERIAL="$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(printf "%06d" $((RANDOM % 30000 + 1)))
|
|
||||||
echo $SERIAL > "$FILE"
|
|
||||||
fi
|
|
||||||
HOST_SERIAL=$(cat "${FILE}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
#If environment variabele not set fall back to file
|
|
||||||
if [ -z "$GUEST_SERIAL" ]; then
|
|
||||||
FILE="${IMG}/guest.serial"
|
|
||||||
if [ ! -f "$FILE" ]; then
|
|
||||||
SERIAL="$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(printf "%06d" $((RANDOM % 30000 + 1)))
|
|
||||||
echo $SERIAL > "$FILE"
|
|
||||||
fi
|
|
||||||
GUEST_SERIAL=$(cat "${FILE}")
|
|
||||||
fi
|
|
||||||
|
|
||||||
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')
|
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')
|
||||||
|
|
||||||
@ -38,18 +19,18 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
./run/serial.bin -cpu="${CPU_CORES}" \
|
./run/serial.bin -cpu="${CPU_CORES}" \
|
||||||
-cpu_arch="${CPU}" \
|
-cpu_arch="${CPU}" \
|
||||||
-buildnumber=42962 \
|
-hostsn="${HOST_SERIAL}" \
|
||||||
-vmmts=1679863686 \
|
-guestsn="${GUEST_SERIAL}" \
|
||||||
-hostsn="${HOST_SERIAL}" \
|
-vmmts="${HOST_TIMESTAMP}" \
|
||||||
-guestsn="${GUEST_SERIAL}" \
|
-vmmversion="${HOST_VERSION}" \
|
||||||
-vmmversion="2.6.1-12139" \
|
-buildnumber="${HOST_BUILD}" \
|
||||||
-guestuuid="ba13a19a-c0c1-4fef-9346-915ed3b98341" > /dev/null 2>&1 &
|
-guestuuid="${GUEST_UUID}" > /dev/null 2>&1 &
|
||||||
|
|
||||||
KVM_SERIAL_OPTS="\
|
KVM_SERIAL_OPTS="\
|
||||||
-serial mon:stdio \
|
-serial mon:stdio \
|
||||||
-device virtio-serial-pci,id=virtio-serial0,bus=pcie.0,addr=0x3 \
|
-device virtio-serial-pci,id=virtio-serial0,bus=pcie.0,addr=0x3 \
|
||||||
-chardev pty,id=charserial0 \
|
-chardev pty,id=charserial0 \
|
||||||
-device isa-serial,chardev=charserial0,id=serial0 \
|
-device isa-serial,chardev=charserial0,id=serial0 \
|
||||||
-chardev socket,id=charchannel0,host=127.0.0.1,port=12345,reconnect=10 \
|
-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"
|
-device virtserialport,bus=virtio-serial0.0,nr=1,chardev=charchannel0,id=channel0,name=vchannel"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user