From 399829cf3cdae8dff0729e9ae50ba81c387acff2 Mon Sep 17 00:00:00 2001 From: Kroese Date: Sat, 4 Oct 2025 09:39:20 +0200 Subject: [PATCH] feat: Make monitor port configurable (#1041) --- src/network.sh | 3 +-- src/power.sh | 12 ++++++------ src/reset.sh | 1 + 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/network.sh b/src/network.sh index 976a4c0..176877a 100644 --- a/src/network.sh +++ b/src/network.sh @@ -183,8 +183,7 @@ getUserPorts() { getHostPorts() { local list="$1" - - [ -z "$list" ] && echo "" && return 0 + [ -z "$list" ] && list="$MON_PORT" || list+=",$MON_PORT" if [[ "$list" != *","* ]]; then echo " ! --dport $list" diff --git a/src/power.sh b/src/power.sh index 0a80c50..fb696fc 100644 --- a/src/power.sh +++ b/src/power.sh @@ -1,15 +1,15 @@ #!/usr/bin/env bash set -Eeuo pipefail +: "${API_TIMEOUT:="50"}" # API Call timeout +: "${QEMU_TIMEOUT:="50"}" # QEMU Termination timeout + # Configure QEMU for graceful shutdown API_CMD=6 API_HOST="127.0.0.1:2210" -: "${API_TIMEOUT:="50"}" # API Call timeout QEMU_TERM="" -QEMU_PORT=7100 -: "${QEMU_TIMEOUT:="50"}" # QEMU Termination timeout QEMU_DIR="/run/shm" QEMU_PID="$QEMU_DIR/qemu.pid" QEMU_LOG="$QEMU_DIR/qemu.log" @@ -83,7 +83,7 @@ terminal() { fi if [ ! -c "$dev" ]; then - dev=$(echo 'info chardev' | nc -q 1 -w 1 localhost "$QEMU_PORT" | tr -d '\000') + dev=$(echo 'info chardev' | nc -q 1 -w 1 localhost "$MON_PORT" | tr -d '\000') dev="${dev#*serial0}" dev="${dev#*pty:}" dev="${dev%%$'\n'*}" @@ -127,7 +127,7 @@ _graceful_shutdown() { fi # Don't send the powerdown signal because vDSM ignores ACPI signals - # echo 'system_powerdown' | nc -q 1 -w 1 localhost "${QEMU_PORT}" > /dev/null + # echo 'system_powerdown' | nc -q 1 -w 1 localhost "$MON_PORT" > /dev/null # Send shutdown command to guest agent via serial port url="http://$API_HOST/read?command=$API_CMD&timeout=$API_TIMEOUT" @@ -172,7 +172,7 @@ _graceful_shutdown() { MON_OPTS="\ -pidfile $QEMU_PID \ -name $PROCESS,process=$PROCESS,debug-threads=on \ - -monitor telnet:localhost:$QEMU_PORT,server,nowait,nodelay" + -monitor telnet:localhost:$MON_PORT,server,nowait,nodelay" if [[ "$CONSOLE" != [Yy]* ]]; then diff --git a/src/reset.sh b/src/reset.sh index 8009050..2f30966 100644 --- a/src/reset.sh +++ b/src/reset.sh @@ -203,6 +203,7 @@ addPackage() { return 0 } +: "${MON_PORT:="7100"}" # Monitor port : "${WEB_PORT:="5000"}" # Webserver port cp -r /var/www/* /run/shm