I am using OpenSUSE and I have created a script that launches at startup the x11vnc server. But when the user logs out x11vnc is killed. I want it to start again automatically. Here the script I wrote. It works perfectly at boot.
#!/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)
#Gets the name of the script
BIN="/usr/bin/x11vnc"
#Binary path
ALLOWED_GROUP=$(getent group g_vnc-usr | awk -F ":" '{ print $4 }')
#Only inf-usr group is allowed to take control of any machine.
AUTH=`ps wwaux | grep '/X.*-auth' | sed -e 's/^.*-auth *//' -e 's/ .*$//' | head -n 1`
OPT="-display :0 -auth ${AUTH} -nopw -unixpw ${ALLOWED_GROUP} -shared -oa /var/log/vnc.log -xkb -bg -verbose -forever"
#Various options of the x11vnc providing auth, user auth, logging and "keep alive" connection.
CMD="${BIN} ${OPT}"
#Both bin and options are stored
. /lib/lsb/init-functions
rc_reset
# Reset status of this service
case "$1" in
start)
echo -n "Starting ${SERVICE}..."
## Start daemon with startproc(8).
/sbin/startproc ${CMD}
##>> /dev/null 2>&1
sleep 2s
# Remember status and be verbose.
rc_status -v
;;
stop)
echo -n "Shutting down ${SERVICE}..."
## Stop daemon with killproc(8)
/sbin/killproc ${BIN}
# Remember status and be verbose
rc_status -v
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
# Remember status and be quiet
rc_status
;;
status)
echo -n "Checking for service ${SERVICE}..."
## Check status with checkproc(8), if process is running
## checkproc will return with exit status 0.
/sbin/checkproc ${BIN}
# Remember status and be verbose
rc_status -v
;;
*)
echo -n
echo -n "Usage: ${SERVICE} {start|stop|restart|status}"
exit 1
;;
esac
rc_exit
This script allows any user from the group to take the machine over even if no one is currently logged in.
I wanted to use xinitrc and to add exec /etc/init.d/vnc restart
Thank you.