Skip to content

Instantly share code, notes, and snippets.

@ladar
Created June 10, 2017 03:03
Show Gist options
  • Save ladar/395b2c8a2e5103c34472f3fea4dd53de to your computer and use it in GitHub Desktop.
Save ladar/395b2c8a2e5103c34472f3fea4dd53de to your computer and use it in GitHub Desktop.
Shell script used to connect with the packer builds currently under construction.
#!/bin/bash
# Sudo is needed to find the vmware-vmx ports.
PORT=`sudo netstat -pnl 2>&1 | grep tcp | grep -E "vmware-vmx|qemu|qemu-kvm" | awk -F':' '{print $2}' | awk -F' ' '{print $1}' | grep -E "^59"`
for p in $PORT; do
#rpm -q virt-viewer &> /dev/null || (printf "\n\nA VNC port was detected, but the Virt Viewer doesn't appear to be available.\n\n" && exit 1)
#remote-viewer vnc://127.0.0.1:$p &> /dev/null &
rpm -q vinagre &> /dev/null || (printf "\n\nA VNC port was detected, but Vinagre doesn't appear to be available.\n\n" && exit 1)
vinagre --vnc-scale vnc://127.0.0.1:$p &> /dev/null &
done
# Sudo is also needed to find the virtualbox ports.
PORT=`sudo netstat -pnl 2>&1 | grep tcp | grep "VBoxHeadless" | awk -F':' '{print $2}' | awk -F' ' '{print $1}' | grep -E "^59"`
for p in $PORT; do
rpm -q vinagre &> /dev/null || (printf "\n\nAn RDP port was detected, but Vinagre doesn't appear to be available.\n\n" && exit 1)
vinagre --vnc-scale rdp://127.0.0.1:$p &> /dev/null &
done
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment