Created
June 3, 2011 10:16
-
-
Save artemave/1006135 to your computer and use it in GitHub Desktop.
setup vnc server for any subsequent process (like cucumber -> firefox) to use vnc display
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
def _vnc_setup | |
d = '22' # vnc desktop number | |
ENV['DISPLAY'] = "localhost:#{d}" | |
hostname = `hostname`.chomp | |
vnc_pid_file = File.join(ENV['HOME'], ".vnc", "#{hostname}:#{d}.pid") | |
if File.exist?(vnc_pid_file) | |
pid = File.open(vnc_pid_file).read.chomp | |
log "Xvnc appears to be already running with pid #{pid}" | |
if `/bin/ps -p #{pid}`.split.last =~ /Xvnc/ | |
return | |
else | |
log "old pid file found #{vnc_pid_file} . killing and removing.." | |
log "vncserver -kill :#{d}" | |
log `vncserver -kill :#{d}` | |
log "rm #{vnc_pid_file}" | |
log `rm #{vnc_pid_file}` | |
end | |
else | |
log "vnc pid file not found #{vnc_pid_file}" | |
end | |
log "starting new vncserver" | |
log "vncserver -geometry 1200x1200 -depth 24 :#{d}" | |
fork do | |
daemonize | |
`vnc4server -geometry 1200x1200 -depth 24 :#{d}` | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment