diff --git a/bastion/src/bastion/src/templates/install.ks.ts b/bastion/src/bastion/src/templates/install.ks.ts index 019bbb8..af2d94a 100644 --- a/bastion/src/bastion/src/templates/install.ks.ts +++ b/bastion/src/bastion/src/templates/install.ks.ts @@ -121,7 +121,8 @@ ${userDirective} bootloader --append="console=tty0 console=ttyS0,115200n8" -logging --host=${serverIp} --port=${syslogPort} +# logging --host=${serverIp} --port=${syslogPort} +# Disabled: syslog UDP port needs to be exposed in k3s service/hostPort first url --mirrorlist=https://mirrors.fedoraproject.org/mirrorlist?repo=fedora-$releasever&arch=$basearch diff --git a/bastion/tests/integration/helpers/jetkvm.sh b/bastion/tests/integration/helpers/jetkvm.sh new file mode 100755 index 0000000..e9ecbb3 --- /dev/null +++ b/bastion/tests/integration/helpers/jetkvm.sh @@ -0,0 +1,82 @@ +#!/bin/bash +# JetKVM helper — authenticate and interact with JetKVM device. +# Usage: +# jetkvm.sh status — check device status +# jetkvm.sh reboot — reboot the target machine via ATX +# jetkvm.sh poweron — power on via ATX short press +# jetkvm.sh poweroff — power off via ATX long press +# +# Environment: +# JETKVM_HOST — JetKVM IP (default: 192.168.3.10) +# JETKVM_PASS — device password + +set -euo pipefail + +HOST="${JETKVM_HOST:-192.168.3.10}" +PASS="${JETKVM_PASS:-}" + +if [ -z "$PASS" ]; then + echo "ERROR: JETKVM_PASS not set" >&2 + exit 1 +fi + +BASE="http://$HOST" + +# Authenticate and get token +login() { + local resp + resp=$(curl -s -X POST "$BASE/auth/login-local" \ + -H "Content-Type: application/json" \ + -d "{\"password\":\"$PASS\"}" 2>&1) + + local token + token=$(echo "$resp" | grep -oP '"token"\s*:\s*"[^"]*"' | head -1 | grep -oP '"[^"]*"$' | tr -d '"') + + if [ -z "$token" ]; then + echo "ERROR: Login failed: $resp" >&2 + exit 1 + fi + echo "$token" +} + +# Make authenticated request +api() { + local method="$1" path="$2" body="${3:-}" + local token + token=$(login) + + if [ -n "$body" ]; then + curl -s -X "$method" "$BASE$path" \ + -H "Authorization: Bearer $token" \ + -H "Content-Type: application/json" \ + -d "$body" + else + curl -s -X "$method" "$BASE$path" \ + -H "Authorization: Bearer $token" + fi +} + +case "${1:-status}" in + status) + curl -s "$BASE/device/status" 2>&1 + ;; + device) + api GET /device + ;; + reboot) + echo "Sending ATX reset..." + api POST /device/atx/reset + ;; + poweron) + echo "Sending ATX short power press..." + api POST /device/atx/power-short + ;; + poweroff) + echo "Sending ATX long power press..." + api POST /device/atx/power-long + ;; + *) + echo "Usage: $0 {status|device|reboot|poweron|poweroff}" + exit 1 + ;; +esac