tiny-pilot / tinypilot

Use your Raspberry Pi as a browser-based KVM.
https://tinypilotkvm.com
MIT License
3k stars 252 forks source link

Reimplement `/boot/config.txt` logic in postinst script #1594

Closed mtlynch closed 1 year ago

mtlynch commented 1 year ago

The uStreamer Ansible role currently makes two modifications to /boot/config.txt if the TC358743 is enabled:

It adds the line dtoverlay=tc358743-audio immediately after the line dtoverlay=tc35843:

https://github.com/tiny-pilot/tinypilot/blob/c0d8e10628afe0ca5ff2116308a51c3c1e21f9a3/ansible-role-ustreamer/tasks/provision_tc358743.yml#L2-L8

It writes gpu_mem=256 at the end of the file or overwrites the line if a line beginning with gpu_mem= already exists in the file:

https://github.com/tiny-pilot/tinypilot/blob/c0d8e10628afe0ca5ff2116308a51c3c1e21f9a3/ansible-role-ustreamer/tasks/provision_tc358743.yml#L10-L16

We can reimplement this logic in tinypilot.postinst to trim out Ansible logic.

We have an example of checking for if TC358743 is enabled:

https://github.com/tiny-pilot/tinypilot/blob/572ee6acfd459946ce9a5b4a448d31f6dd4cbdca/debian-pkg/debian/tinypilot.postinst#L119

It's a little bit out of scope, but we should also take this opportunity to reimplement janus.plugin.ustreamer.jcfg in the tinypilot.postinst using render-template. That way, we can test the changes all at the same time, and it lets us completely get rid of all the Ansible logic around /boot/config.txt:

https://github.com/tiny-pilot/tinypilot/blob/c0d8e10628afe0ca5ff2116308a51c3c1e21f9a3/ansible-role-ustreamer/tasks/main.yml#L2-L27