linux-usb-gadgets / gt

Gadget-tool - Linux command line tool for setting USB gadget using configFS
Apache License 2.0
150 stars 37 forks source link

Service running? #17

Open AstraLuma opened 4 years ago

AstraLuma commented 4 years ago

Ok, so I'm reading https://www.collabora.com/news-and-blog/blog/2019/03/27/modern-usb-gadget-on-linux-and-how-to-integrate-it-with-systemd-part-2/ and i'm like.... this is nuts. (I have an uneasy truce with systemd on the best of days.)

Could gt learn to start a service, the process being:

  1. load the scheme
  2. mount the ffs
  3. start the service
  4. enable the gadget
  5. Wait on the service (with signal forwarding?)
  6. Unmount the ffs
  7. remove the scheme
  8. return the return code of the service

It doesn't need to do full daemon management, just wrap another program to do the necessary usb init/etc.

For the record, I'm using gt with https://github.com/viveris/uMTP-Responder/ because I wrote my own script to do all this and having an actual declarative file is much nicer.

pabs3 commented 3 years ago

@AstraLuma I think that would be fragile and it would be better to do the above in an event driven way using the systemd dependencies mentioned in the post from @andrzejtp you linked above.

@andrzejtp I think that we should import more of the setup in the blog post above, but instanced, so you can drop your scheme in /etc/gt/ffs/foo.scheme, configure which daemon service to start and then start an instance of the relevant services. Thoughts?

BTW @andrzejtp added some of their systemd setup to gt in commit ed35e2f