The officially official Devuan Forum!

You are not logged in.

#1 2019-05-23 21:19:23

ea4170@0c5
Member
Registered: 2019-05-23
Posts: 2  

Create new service from systemd x11vnc.service

Hello folks,

I use x11vnc on devuan.
I can manually launch x11vnc and then connect from another computer to the devuan computer.
But when I exit the connection, the x11vnc terminates.
Then I found debian users creating a service configuration file for automatic restarting the x11vnc program after exiting, and automatic start when booting.
I would like to adapt this "x11vnc.service" for devuan but I did not find how to do this on Dev1 Galaxy.
Please tell me how to adapt the following x11vnc.service (systemd syntax)

[Unit]
Description=VNC Server for X11
Requires=display-manager.service
After=display-manager.service
BindsTo=display-manager.service
PartOf=display-manager.service

[Service]
Type=simple
ExecStart=/usr/bin/x11vnc -xkb -repeat -allow 127.0.0.1 -display :0 -auth guess -rfbauth /etc/X11/x11vnc.passwd -rfbport 5900 -forever -loop -o /var/log/x11vnc.log
Restart=on-failure
RestartSec=10

This topic can be generalized to any new service needing portability from systemd or any system service manager.

Best regards,
from ea4170@0c5

Offline

#2 2019-05-24 13:53:36

GNUser
Member
Registered: 2017-03-16
Posts: 570  

Re: Create new service from systemd x11vnc.service

Hi, ea4170. I did some copy and pasting and came up with this. It is untested, but something to get you started:

#!/bin/sh
### BEGIN INIT INFO
# Provides:		x11vnc
# Required-Start:
# Required-Stop:
# Should-Start:	     
# Should-Stop:       
# X-Start-After:	lightdm
# Default-Start:	2 3 4 5
# Default-Stop:		0 1 6		
# Short-Description:	VNC Server for X11
# Description:		VNC Server for X11 
### END INIT INFO

case "$1" in
  start)
	while true; do
		/usr/bin/x11vnc -xkb -repeat -allow 127.0.0.1 -display :0 -auth guess -rfbauth /etc/X11/x11vnc.passwd -rfbport 5900 -forever -loop -o /var/log/x11vnc.log
	done
	;;
  stop)
	pkill x11vnc
	sleep 1
	pkill -KILL x11vnc
	;;
esac

exit 0

To test it:
1. Replace lightdm if appropriate (run # service --status-all or $ ls /etc/init.d to find the name of your display manager service)
2. Name the above script x11vnc, put it in /etc/init.d/, and make it executable
3. # update-rc.d x11vnc defaults

Good luck. Let me know how it goes.

P.S. I haven't used any vnc applications in a long time. If -forever -loop already gives you automatic restarting, delete the while true; do and done lines from my script.

Last edited by GNUser (2019-05-24 13:57:24)

Offline

#3 2019-05-27 22:06:02

ea4170@0c5
Member
Registered: 2019-05-23
Posts: 2  

Re: Create new service from systemd x11vnc.service

Thanks, GNUser,

Your script was very usefull.
A few adaptations needed like use of Define LSB log_* functions, or start-stop-daemon function.
I created my own x11vnc.sh script to invoke /usr/bin/x11vnc with adequate parameters and shell background invocation.

I do use x11vnc because this indirection allows me to display the same screen I have on my desktop on the smart tv screen without smart tv screen definition restriction (I have a very large smart tv so this solution enables a partially visual disabled user to develop on devuan.

If someone needs more explaination on how to use this x11vnc scripts, please ask on this forum.

Best regards,
ea4170@0c5

Offline

Board footer