x11vnc startup script

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 :

#!/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=`ps wwaux | grep '/X.*-auth' | grep -v grep | sed -e 's/^.*-auth *//' -e 's/ .*$//' | head -n 1`
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 :


 02/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.

Do I have to change the priority of boot scripts ?

Any idea ?
Thanks

On 2012-07-03 15:16, igor012 wrote:
> When launching it from the command line it works but it doesn’t on
> boot.

YOu have to make sure you are using systemV, and then run “chkconfig x11vnc on”


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

Hi,

chkconfig vnc on is already set and I am using **systemd-sysvinit
**
Thanks

On 2012-07-03 16:56, igor012 wrote:
>
> Hi,
>
> chkconfig vnc on is already set and I am using *systemd-sysvinit
> *

Systemd does not guarantee the order. Intended feature.


Cheers / Saludos,

Carlos E. R.
(from 11.4 x86_64 “Celadon” at Telcontar)

I found what was the problem.

I changed the head from this:

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

To this

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

It starts after xdm has fully booted.

Thanks for your time