Docker

From Sundtek Wiki
Revision as of 12:52, 1 November 2022 by Sundtek (talk | contribs) (→‎Unraid)
Jump to navigation Jump to search

Docker

External Documentation

  • Synology Wiki (German):

https://www.synology-wiki.de/index.php/TvHeadend_mit_Docker_und_Sundtek_SkyTV_Ultimate

On the host

This is the step that has to be taken care about on the native host (outside of the docker image). The driver can run in non-privileged mode inside the docker. Various libc / musl / uclibc images are supported.

If you want to install the linux driver in a docker environment a few things need to be taken care of.

Device Nodes on the Host

Very important /dev/bus/usb contain the interface to the raw USB devices which is used by the sundtek driver. However one special (and a little bit messy part of docker) is that it also needs to know the major/minor IDs which are allowed to be forwarded - before creating and before starting the docker image, that's why nodes in /dev/dvb need to be pre-created on the host.

If you install the driver on the host you should create a configuration file which contains following text: enabledocker=on

this will cause that the driver on the native host (not in the docker) will create dummy adapter nodes in /dev/dvb, the driver itself will not try to access the USB device - it will only create the files if enabledocker=on is set in the configuration file and exit immediately.
On the host:

sudo -s
echo "enabledocker=on" > /etc/sundtek.conf

You can also create them manually if you want (see next section):

Without installing the driver on the host

So the driver on the host has no special function it would just create /dev/dvb devicenodes and exist immediately. You can create those dummies manually (but those need to be there before creating the docker image and before starting the docker image)

mkdir -p /dev/dvb/adapter0
mknod /dev/dvb/adapter0/frontend0 c 212 1
mknod /dev/dvb/adapter0/dvr0 c 212 5
mknod /dev/dvb/adapter0/demux0 c 212 3
mkdir -p /dev/dvb/adapter1
mknod /dev/dvb/adapter1/frontend0 c 212 7
mknod /dev/dvb/adapter1/dvr0 c 212 11
mknod /dev/dvb/adapter1/demux0 c 212 9
mkdir -p /dev/dvb/adapter2
mknod /dev/dvb/adapter2/frontend0 c 212 13
mknod /dev/dvb/adapter2/dvr0 c 212 17
mknod /dev/dvb/adapter2/demux0 c 212 15
Synology NAS

You can install the driver on the host and check the option "Enable Docker" in the Configuration menu. When this is checked the driver will only create those dummy nodes on the host and exit immediately.

Creating a Docker Image

The docker itself needs to be created with some -device flags

docker create --name alpinelinux 
                     --net=bridge 
                     -p 9981:9981 
                     -p 9982:9982 
                     --device=/dev/dvb 
                     --device=/dev/bus/usb 
                     -t alpine /bin/sh 

Inside the docker

Inside the docker unfortunately you only have one shot if you do it wrong you have to re-create the docker and re-do this step. Usually our customers install the drivers inside the docker in /config

To enter a docker image:

docker exec -it tvheadend /bin/sh

Download the netinstall script:

wget http://sundtek.de/media/sundtek_netinst.sh
chmod 777 sundtek_netinst.sh
./sundtek_netinst.sh -docker -use-custom-path /config

The installer will rename the tvheadend binary in /usr/bin to tvheadend.bin and places a script instead which will automatically start the driver.

this will place the driver in /config

Usually you will want to mount a local directory inside the docker, this can basically be configured via the Synology Webfrontend. When doing that you need to take care that the user inside the docker also has access to that folder otherwise you will get a permission denied.

You can use the tvheadend start script to change the permissions if you need that, /usr/bin/tvheadend add chmod 777 /path/to/videodirectory

Misc

one customer also needed to modify the preset current limit of the tuner, he had to place lnblimit=1000ma (case sensitive in sundtek.conf inside the docker)

Unraid

All the sundtek devices work with Unraid.


1. Set up the driver on the host system

Open a terminal as root (console) and run:

cd /tmp
wget http://sundtek.de/media/sundtek_netinst.sh
chmod 777 sundtek_netinst.sh
./sundtek_netinst.sh -dockerhost

(this will only take care that some dummy nodes are created in /dev/dvb/, access control will be handled by major/minor numbers of the existing files. When the driver is started on the host it will exit directly due to the dockerhost flag and only create the nodes)

2. Set up the driver inside the tvheadend docker

... install the tvheadend docker, add an extra device driver for /dev/bus/usb

open the host terminal and enter the tvheadend docker image:

docker exec -it tvheadend /bin/sh
cd /tmp
wget http://sundtek.de/media/sundtek_netinst.sh
chmod 777 sundtek_netinst.sh
./sundtek_netinst.sh -docker -use-custom-path /config

(this will rename the tvheadend binary to tvheadend.bin and put a script in between which will start the driver inside the docker - followed by the actual tvheadend binary).


3. that's it restart the tvheadend docker.