Getting Xvfb to start upon booting system in Ubuntu Maverick

rc.localstartup-scriptsubuntu-10.10x11

I'm trying to get Xvfb to run when the system starts up on Ubuntu 10.10 (Maverick), but it's not working. In /etc/rc.local, I have the following:

/root/start_xvfb.sh >> /var/log/start_xvfb.log 2>&1
exit 0

And in /root/start_xvfb.sh I have:

#!/bin/sh -e
startx -- `which Xvfb` :0 -screen 0 1024x768x24 &
exit 0

After rebooting the machine, the log file (/var/log/start_xvfb.log) contains:

[dix] Could not init font path element /usr/share/fonts/X11/cyrillic, removing from list!
^M
waiting for X server to shut down
^M

Given that content in the log file, it seems like the call to "startx — `which Xvfb` :0 -screen 0 1024x768x24" is being made, but the process is killed soon thereafter.

I want to start Xvfb on boot because I need to run Firefox on a remote server that doesn't have a monitor display. If I run /etc/rc.local after SSH'ing to the remote machine, Xvfb starts without a problem and I can launch Firefox via "firefox –display=:0 &". If I try to run Firefox using that command without first starting Xvfb, I get the message "Error: cannot open display: :0".

Note that I am not trying to actually see the display on my local workstation. I want the application to display on the remote machine's (virtual, in memory) display.

Any ideas why X server is shutting down on the remote machine immediately after it starts? Is there a better way to have Xvfb start upon system boot?

Thanks in advance for any help.

Best Answer

I suppose the shell TERMs it when it exits, which would be immediately, due to the '&'. Maybe you want to use start-stop-daemon? E.g:

start-stop-daemon --start -b -x /usr/bin/Xvfb :1

I suppose if you want the help of the startx wrapper, you may want to run your shellscript instead.