Advertisement
callebstrom

Virtual display + x11vnc for headless selenium and monitorin

Dec 18th, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.90 KB | None | 0 0
  1. #!/bin/bash
  2. #Check user
  3.  
  4.  
  5. if [[ $USER != "root" ]]; then
  6.                 echo "This script must be run as root!"
  7.                 exit 1
  8. fi
  9.  
  10. #Run Xvfb with default settings as background job (RANDR mod + display port 99, firefox arg isn't really used)
  11. #xvfb-run --server-args="-screen 0, 1920x1080x24" firefox &
  12. Xvfb :99 -screen 0, 1920x1080x24 -nolisten tcp &
  13.  
  14. sleep 5
  15.  
  16. #Run x11vnc server on all interfaces, points to display 99, does not die on 0 users
  17. x11vnc -shared -forever -display :99 -listen 0.0.0.0 &
  18.  
  19. netstat -pnlt | grep ':5900' | echo $(awk '{print $7}') | grep -o '[0-9]\+' | sudo kill $(awk '{print $0}') > /dev/null 2> /dev/null
  20.  
  21. CMD=$(sudo netstat -pnlt | grep ':5900')
  22.  
  23. if [ -z $CMD ]
  24. then
  25.     echo "VNC server started successfully.."
  26.     #Disturb everyone
  27.     wall remote display for selenium can be reached on all interfaces, port:5900
  28. else
  29.     echo "Failed to start VNC server"
  30. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement