Advertisement
Guest User

Untitled

a guest
Sep 20th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. apt-get install jq -y
  4. ps axu | grep -oe "unix:[a-z0-9\.:\/\-]*.qmp" | while read QMP; do
  5. echo $QMP;
  6. LISTEN=$(echo -e '{"execute":"qmp_capabilities"}\n{"execute": "query-vnc"}' | socat - ${QMP} | tail -n1 | jq -r .return.host);
  7. echo $LISTEN
  8. if [ "$LISTEN" != "127.0.0.1" ]; then
  9. PORT=$[$(echo -e '{"execute":"qmp_capabilities"}\n{"execute": "query-vnc"}' | socat - ${QMP} | tail -n1 | jq -r .return.service)-5900]
  10. echo -e '{"execute":"qmp_capabilities"}\n{"execute": "change", "arguments": { "device": "vnc", "target": "127.0.0.1:'$PORT'" } }' | socat - ${QMP};
  11. fi
  12. done
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement