feat: Make monitor configurable (#379)
This commit is contained in:
parent
4a0dbc6c06
commit
2fdb19ae40
4 changed files with 88 additions and 9 deletions
|
@ -60,11 +60,14 @@ if [[ "${BOOT_MODE,,}" != "legacy" ]]; then
|
|||
|
||||
if [[ "$TPM" == [Yy1]* ]]; then
|
||||
|
||||
rm -rf /run/shm/tpm
|
||||
rm -f /var/run/tpm.pid
|
||||
mkdir -p /run/shm/tpm
|
||||
chmod 755 /run/shm/tpm
|
||||
swtpm socket -t -d --tpmstate dir=/run/shm/tpm --ctrl type=unixio,path=/run/swtpm-sock --tpm2
|
||||
|
||||
for (( i = 1; i < 50; i++ )); do
|
||||
swtpm socket -t -d --tpmstate dir=/run/shm/tpm --ctrl type=unixio,path=/run/swtpm-sock --pid file=/var/run/tpm.pid --tpm2
|
||||
|
||||
for (( i = 1; i < 20; i++ )); do
|
||||
|
||||
[ -S "/run/swtpm-sock" ] && break
|
||||
|
||||
|
|
|
@ -1,10 +1,13 @@
|
|||
#!/usr/bin/env bash
|
||||
set -Eeuo pipefail
|
||||
|
||||
: "${SERIAL:="mon:stdio"}"
|
||||
: "${MONITOR:="telnet:localhost:7100,server,nowait,nodelay"}"
|
||||
|
||||
DEF_OPTS="-nodefaults"
|
||||
SERIAL_OPTS="-serial mon:stdio"
|
||||
SERIAL_OPTS="-serial $SERIAL"
|
||||
MON_OPTS="-monitor $MONITOR"
|
||||
USB_OPTS="-device qemu-xhci -device usb-tablet"
|
||||
MON_OPTS="-monitor telnet:localhost:7100,server,nowait,nodelay"
|
||||
RAM_OPTS=$(echo "-m $RAM_SIZE" | sed 's/MB/M/g;s/GB/G/g;s/TB/T/g')
|
||||
CPU_OPTS="-cpu $CPU_FLAGS -smp $CPU_CORES,sockets=1,dies=1,cores=$CPU_CORES,threads=1"
|
||||
MAC_OPTS="-machine type=q35${SECURE},graphics=off,vmport=off,dump-guest-core=off,hpet=off${KVM_OPTS}"
|
||||
|
|
|
@ -193,6 +193,36 @@ configureNAT() {
|
|||
return 0
|
||||
}
|
||||
|
||||
closeNetwork() {
|
||||
|
||||
# Shutdown nginx
|
||||
nginx -s stop 2> /dev/null
|
||||
fWait "nginx"
|
||||
|
||||
exec 30<&- || true
|
||||
exec 40<&- || true
|
||||
|
||||
if [[ "$DHCP" == [Yy1]* ]]; then
|
||||
|
||||
ip link set "$VM_NET_TAP" down || true
|
||||
ip link delete "$VM_NET_TAP" || true
|
||||
|
||||
else
|
||||
|
||||
local pid="/var/run/dnsmasq.pid"
|
||||
[ -f "$pid" ] && pKill "$(<"$pid")"
|
||||
|
||||
ip link set "$VM_NET_TAP" down promisc off || true
|
||||
ip link delete "$VM_NET_TAP" || true
|
||||
|
||||
ip link set dockerbridge down || true
|
||||
ip link delete dockerbridge || true
|
||||
|
||||
fi
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
getInfo() {
|
||||
|
||||
if [ -z "$VM_NET_DEV" ]; then
|
||||
|
|
53
src/reset.sh
53
src/reset.sh
|
@ -24,7 +24,7 @@ echo
|
|||
: "${RAM_SIZE:="1G"}" # Maximum RAM amount
|
||||
: "${DISK_SIZE:="16G"}" # Initial data disk size
|
||||
: "${BOOT_INDEX:="10"}" # Boot index of CD drive
|
||||
|
||||
|
||||
# Helper variables
|
||||
|
||||
STORAGE="/storage"
|
||||
|
@ -48,10 +48,54 @@ else
|
|||
fi
|
||||
|
||||
# Check folder
|
||||
[ ! -d "$STORAGE" ] && error "Storage folder ($STORAGE) not found!" && exit 13
|
||||
|
||||
if [ ! -d "$STORAGE" ]; then
|
||||
error "Storage folder ($STORAGE) not found!" && exit 13
|
||||
fi
|
||||
|
||||
# Helper functions
|
||||
|
||||
isAlive() {
|
||||
local pid=$1
|
||||
|
||||
if kill -0 "$pid" 2>/dev/null; then
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
||||
}
|
||||
|
||||
pKill() {
|
||||
local pid=$1
|
||||
|
||||
{ kill -15 "$pid" || true; } 2>/dev/null
|
||||
|
||||
while isAlive "$pid"; do
|
||||
sleep 0.2
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
fWait() {
|
||||
local name=$1
|
||||
|
||||
while pgrep -f -l "$name" >/dev/null; do
|
||||
sleep 0.2
|
||||
done
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
fKill() {
|
||||
local name=$1
|
||||
|
||||
{ pkill -f "$name" || true; } 2>/dev/null
|
||||
fWait "$name"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
escape () {
|
||||
local s
|
||||
s=${1//&/\&}
|
||||
|
@ -89,13 +133,12 @@ html()
|
|||
HTML="${HTML/\[5\]/$FOOTER2}"
|
||||
|
||||
echo "$HTML" > "$PAGE"
|
||||
echo "$body$script" > "$INFO"
|
||||
echo "$body" > "$INFO"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
addPackage () {
|
||||
|
||||
addPackage() {
|
||||
local pkg=$1
|
||||
local desc=$2
|
||||
|
||||
|
|
Loading…
Reference in a new issue