LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   x11vnc at startup (http://www.linuxquestions.org/questions/linux-software-2/x11vnc-at-startup-4175414461/)

igor012 07-02-2012 10:08 AM

x11vnc at startup
 
Hello,
I am using opensuse 12.1 and I am trying to have x11vnc started before login.

I have created a /etc/init.d/vnc file :

Code:

#!/bin/sh
#
# /etc/init.d/vnc
#
### BEGIN INIT INFO
# Provides:          x11vnc server
# Required-Start:    $xdm 
# Should-Start:
# Required-Stop:
# Should-Stop:
# Default-Start:    5
# Default-Stop:      0 1 2 6
# Short-Description:
# Description:      Start or stop vnc server
### END INIT INFO

#INIT SCRIPT VARIABLES
SERVICE=$(basename $0)
PIDFILE="/var/run/${SERVICE}.pid"
BIN="/usr/bin/x11vnc "
AUTH=$(find /var/lib/xdm/authdir/authfiles/A:*)
OPT="-display :0 -auth ${AUTH} -nopw -unixpw -shared -oa /var/log/vnc.log -xkb -bg -verbose  "
CMD=${BIN}${OPT}


. /lib/lsb/init-functions

# Reset status of this service
rc_reset


case "$1" in
    start)
        echo -n "Starting ${SERVICE}..."
        ## Start daemon with startproc(8).
        /sbin/startproc ${CMD}
        sleep 2s
        # Remember status and be verbose.
        rc_status -v
        ;;
    *)
        echo -e "Usage: ${SERVICE} {start}"
        exit 1
        ;;
esac
rc_exit

When launching it from the command line it works but it doesn't on boot.

Here x11vnc log file :
Code:

2/07/2012 19:00:49 x11vnc version: 0.9.12 lastmod: 2010-09-09  pid: 1002
02/07/2012 19:00:49 XOpenDisplay(":0") failed.
02/07/2012 19:00:49 Trying again with XAUTHLOCALHOSTNAME=localhost ...

02/07/2012 19:00:49 ***************************************
02/07/2012 19:00:49 *** XOpenDisplay failed (:0)

*** x11vnc was unable to open the X DISPLAY: ":0", it cannot continue.
*** There may be "Xlib:" error messages above with details about the failure.

Any idea ?
Thanks

timufea 07-03-2012 03:15 AM

The error message probably means that the X server is not running yet. You will have to ensure that the X-server is started before x11vnc.

Since there is no ordinary user logged in at boot-time, the X-server will have to be displaying a login screen - i.e. you will need a display manager such as xdm, gdm or kdm running. See the x11vnc FAQ for how to do this.

KuimFieg 07-03-2012 03:39 AM

I don't know OpenSuse but in Debian (since Lenny I think) you need to grab the XAUTHORITY token.

In my current setup I have to lauch x11vnc with gdm's random token.

Code:

export XAUTHORITY=/var/run/gdm3/auth-for-Debian-gdm-0Y9dhH/database
x11vnc -auth guess

or
Code:

x11vnc -auth /var/run/gdm3/auth-for-Debian-gdm-0Y9dhH/database
Maybe this could help. You have to search for the string XAUTHORITY to find the process allowed to connect to the graphical interface. In otherwords you have to launch x11vnc with gdm's "credentials".
Code:

grep --text auth-for /proc/*/environ| cat -v | sed 's/\^@/\n/g' | less

igor012 07-03-2012 07:54 AM

Hello,

I think timufea is right. This may occur because the X server has not started.
I have tried to change the priorities
Code:

ll /etc/init.d/rc5.d/S11vnc
lrwxrwxrwx 1 root root 6 Jul  3 12:09 /etc/init.d/rc5.d/S11vnc -> ../vnc

It used to be
Code:

/etc/init.d/rc5.d/S10vnc
But it still doesn't work.

Also I have changed how to locate the authfiles by running :
Code:

ps wwaux | grep '/X.*-auth' | grep -v grep | sed -e 's/^.*-auth *//' -e 's/ .*$//' | head -n 1
source

KuimFieg 07-03-2012 10:56 AM

Can you ssh and run x11vnc via your script once fully booted?

igor012 07-03-2012 11:10 AM

Yes indeed
Once booted I can launch it.

igor012 07-03-2012 11:22 AM

I found what was the problem.

I changed the head from this:

Code:

### BEGIN INIT INFO
# Provides:          x11vnc server
# Required-Start:    $xdm

To this
Code:

### BEGIN INIT INFO
# Provides:          x11vnc server
# Required-Start:    xdm

It starts after xdm has fully booted.

Thanks for your time.


All times are GMT -5. The time now is 06:12 PM.