Initial commit
Some checks failed
Build package / build-package (push) Has been cancelled

This commit is contained in:
2024-12-16 20:28:52 +08:00
commit 781fe3dd9e
9 changed files with 232 additions and 0 deletions

12
src/share/stopvm.sh Normal file
View File

@@ -0,0 +1,12 @@
#!/usr/bin/env -S bash
CONFIG_FILE='/etc/vm/config.jsonnet'
vm="$1"
shift
mapfile -t endPoint <<< "$(jsonnet "$CONFIG_FILE" | jq -r ".${vm}[]" | sed -nr 's/^-monitor telnet:(\w+):(\w+).*$/\1\n\2/p')"
nc "${endPoint[0]}" "${endPoint[1]}" <<'EOF'
system_powerdown
EOF