systemd & vnc - how to properly handle /etc/sysconfig/vncservers

Lennart Poettering mzerqung at 0pointer.de
Wed Jul 20 17:17:33 UTC 2011


On Wed, 20.07.11 11:48, Adam Tkac (atkac at redhat.com) wrote:

> Hello all,
> 
> I'm trying to package systemd service file for tigervnc server and to
> find a solution how to make it backward-compatible with current format
> of the /etc/sysconfig/vncservers.
> 
> Current /etc/sysconfig/vncservers has following options (example):
> 
> VNCSERVERS="1:user1 2:user2"
> VNCSERVERARGS[1]="-arg1 -arg2"
> VNCSERVERARGS[2]="-arg3 -arg4"
> 
> With arguments above traditional SysV initscript starts Xvnc instances
> for displays :1 and :2 which run under appropriate user (user1 and user2
> in this example) and passes arguments to Xvnc.
> 
> If I understand systemd correctly it's a bad idea to try start multiple
> instances of the Xvnc via one systemd service file - I'm fine with this,
> admin will have to create multiple service files for multiple Xvnc
> instances.
> 
> However is there any way how to extract correct bits from the sysconfig
> file? I think it's easy with the VNCSERVERARGS[num] variable but I don't
> have any idea how to extract proper user from the VNCSERVERS variable.
> Does systemd support some kind of regex matching for the $<name> 
> variables got from sysconfig files?
> 
> Any idea how to handle the VNCSERVERS argument in backward-compatible
> way is welcomed, otherwise I will simply drop sysconfig support at all
> in the service file and admin will have to create /etc/systemd/system/
> service files with appropriate params.

You have a couple two options here:

a) I think this is one of the cases where the configuration in sysconfig
is just too cumbersome and a proper configuration file would bre really
useful. (It might even be an option to just fold this into gdm, so that
clients dynamically get a new screen). This of course requires hacking
vnc and/or gnome, so is not a short-term thing.

b) If you want to keep full compatibility with the sysconfig file, place
a start-up script in /usr/lib/vnc/start-vncserver-instance or so, which parses
it. Then, use instantiated systemd services, to instantiate individual
ones. Example:

<snip>
[Unit]
Description=VNC for %i

[Service]
ExecStart=/usr/lib/vnc/start-vnc-instance %i
</snip>

Place that in /lib/systemd/vncserver at .service or so. If a user then
wants to start a vnc server for a user, it is sufficien to run
"systemctl start vncserver at 1:lennart.service" which would then cause
"/usr/lib/vnc/start-vnc-instance 1:lennart" to be started. Or, to make
this permanent: "ln -s /lib/systemd/vncserver at .service
/etc/systemd/multi-user.target.wants/vncserver at 1:lennart.service".

Presumably most users will just use the same vnc server configuration,
and hence a couple of "ln -s" would be everything needed to instantiate
vnc for the users. If there's point in passing specific arguments to the
service for a specific user, then the admin should just copy
/lib/systemd/vncserver at .service to
/etc/systemd/vncserver at 1:lennart.service and edit it there. You can do
this for individual users.

Hope this clears some things up.

Lennart

-- 
Lennart Poettering - Red Hat, Inc.


More information about the devel mailing list