LXD pre init and post init scripts

Hi I am still in the process of converting my lxc container to lxd.

  1. I am looking for a script to replace lxc.hook.autodev ,which in my case is a script that create
    a bunch of nknode (privileged container) and copies /dev/input/* devices from the host to the container.
  2. A script that runs after mounting all the devices, but before the other init scripts start. In my case it is lxc.hook.start. It is basically creating xorg config files with all the evdev devices that can be found in /dev/input

Any help will be appreciated.

LXD as a principle does not have hooks as those don’t really work well in a multi-server world and are also a major PITA when dealing with user bug reports.

That being said, I don’t think you really need them in your case.

  1. This can likely be solved with some unix-char devices. For the /dev/input case, you could probably use a disk device to bind-mount /dev/input into the container directly. Matching that with a raw.lxc entry for the matching lxc.cgroup.devices.allow to allow access to them.

  2. Any reason to do this through a hook rather than just have an early init script in the container generate that config?

Thanks. I agree with you it is better to do without hooks. I’ll try it. For (2) I need to create an xorg.conf with all the evdev devices so that I can have a keyboard and mouse for the container’s xserver. So I basically need to do it in the early stages of the init before the Xerver starts (my situation is different then most) I would like to have multiple Xserver of different linux distributions running on the same machine and sharing the GPU without using VM (I have been doing it with lxc for many years).