mirror of
https://github.com/vdsm/virtual-dsm.git
synced 2025-06-08 17:37:58 +08:00
Serial from environment
This commit is contained in:
parent
6f3e483346
commit
5264a890af
10
serial.sh
10
serial.sh
@ -1,24 +1,34 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Docker environment variabeles
|
||||||
|
: ${HOST_SERIAL:=''}
|
||||||
|
: ${GUEST_SERIAL:=''}
|
||||||
|
|
||||||
permanent="DSM"
|
permanent="DSM"
|
||||||
serialstart="2000"
|
serialstart="2000"
|
||||||
|
|
||||||
IMG="/storage"
|
IMG="/storage"
|
||||||
[ ! -d "$IMG" ] && echo "Storage folder (${IMG}) not found!" && exit 69
|
[ ! -d "$IMG" ] && echo "Storage folder (${IMG}) not found!" && exit 69
|
||||||
|
|
||||||
|
#If environment variabele not set fall back to file
|
||||||
|
if [ -z "$HOST_SERIAL" ]; then
|
||||||
FILE="${IMG}/host.serial"
|
FILE="${IMG}/host.serial"
|
||||||
if [ ! -f "$FILE" ]; then
|
if [ ! -f "$FILE" ]; then
|
||||||
SERIAL="$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(printf "%06d" $((RANDOM % 30000 + 1)))
|
SERIAL="$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(printf "%06d" $((RANDOM % 30000 + 1)))
|
||||||
echo $SERIAL > "$FILE"
|
echo $SERIAL > "$FILE"
|
||||||
fi
|
fi
|
||||||
HOST_SERIAL=$(cat "${FILE}")
|
HOST_SERIAL=$(cat "${FILE}")
|
||||||
|
fi
|
||||||
|
|
||||||
|
#If environment variabele not set fall back to file
|
||||||
|
if [ -z "$GUEST_SERIAL" ]; then
|
||||||
FILE="${IMG}/guest.serial"
|
FILE="${IMG}/guest.serial"
|
||||||
if [ ! -f "$FILE" ]; then
|
if [ ! -f "$FILE" ]; then
|
||||||
SERIAL="$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(printf "%06d" $((RANDOM % 30000 + 1)))
|
SERIAL="$(echo "$serialstart" | tr ' ' '\n' | sort -R | tail -1)$permanent"$(printf "%06d" $((RANDOM % 30000 + 1)))
|
||||||
echo $SERIAL > "$FILE"
|
echo $SERIAL > "$FILE"
|
||||||
fi
|
fi
|
||||||
GUEST_SERIAL=$(cat "${FILE}")
|
GUEST_SERIAL=$(cat "${FILE}")
|
||||||
|
fi
|
||||||
|
|
||||||
./run/serial.bin -cpu=$CPU_CORES \
|
./run/serial.bin -cpu=$CPU_CORES \
|
||||||
-buildnumber=42962 \
|
-buildnumber=42962 \
|
||||||
|
Loading…
x
Reference in New Issue
Block a user