Millorable, per conectar-se a la sessió X en curs via SSH pel port 5700
(Cal reiniciar el servei quan se surt de la sessió)
#!/bin/bash
#
# /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 -rfbport 5700 -nossl -auth ${AUTH} -forever -localhost -nolookup -nopw -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
;;
stop)
killall x11vnc
;;
*)
echo -e "Usage: ${SERVICE} {start;stop}"
exit 1
;;
esac
rc_exit