Last active
September 20, 2017 18:00
-
-
Save jkapusi/bef4f56387c15d085ad8d529ff6b4538 to your computer and use it in GitHub Desktop.
quick and dirty solution to bind vnc to localhost on a qemu host
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
apt-get install jq -y | |
ps axu | grep -oe "unix:[a-z0-9\.:\/\-]*.qmp" | while read QMP; do | |
echo $QMP; | |
LISTEN=$(echo -e '{"execute":"qmp_capabilities"}\n{"execute": "query-vnc"}' | socat - ${QMP} | tail -n1 | jq -r .return.host); | |
echo $LISTEN | |
if [ "$LISTEN" != "127.0.0.1" ]; then | |
PORT=$[$(echo -e '{"execute":"qmp_capabilities"}\n{"execute": "query-vnc"}' | socat - ${QMP} | tail -n1 | jq -r .return.service)-5900] | |
echo -e '{"execute":"qmp_capabilities"}\n{"execute": "change", "arguments": { "device": "vnc", "target": "127.0.0.1:'$PORT'" } }' | socat - ${QMP}; | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment