Sfoglia il codice sorgente

fix video device permissions

aptalca 7 anni fa
parent
commit
5615df900e
3 ha cambiato i file con 39 aggiunte e 0 eliminazioni
  1. 4 0
      README.md
  2. 1 0
      readme-vars.yml
  3. 34 0
      root/etc/cont-init.d/50-gid-video

+ 4 - 0
README.md

@@ -242,6 +242,9 @@ Below are the instructions for updating containers:
   containrrr/watchtower \
   --run-once tvheadend
   ```
+
+**Note:** We do not endorse the use of Watchtower as a solution to automated updates of existing Docker containers. In fact we generally discourage automated updates. However, this is a useful tool for one-time manual updates of containers where you have forgotten the original parameters. In the long term, we highly recommend using Docker Compose.
+
 * You can also remove the old dangling images: `docker image prune`
 
 ## Building locally
@@ -265,6 +268,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
 
 ## Versions
 
+* **02.08.19:** - Attempt to automatically fix permissions on /dev/dri and /dev/dvb.
 * **28.06.19:** - Rebasing to alpine 3.10.
 * **27.03.19:** - Rebase to Alpine 3.9, fix init logic to only chown once.
 * **23.03.19:** - Switching to new Base images, shift to arm32v7 tag.

+ 1 - 0
readme-vars.yml

@@ -125,6 +125,7 @@ app_setup_block: |
 
 # changelog
 changelogs:
+  - { date: "02.08.19:", desc: "Attempt to automatically fix permissions on /dev/dri and /dev/dvb." }
   - { date: "28.06.19:", desc: "Rebasing to alpine 3.10." }
   - { date: "27.03.19:", desc: "Rebase to Alpine 3.9, fix init logic to only chown once." }
   - { date: "23.03.19:", desc: "Switching to new Base images, shift to arm32v7 tag." }

+ 34 - 0
root/etc/cont-init.d/50-gid-video

@@ -0,0 +1,34 @@
+#!/usr/bin/with-contenv bash
+
+# check for the existence of a video and/or tuner device
+if [ -e /dev/dri ] || [ -e /dev/dvb ]; then
+	if [ -e /dev/dri ]; then
+		VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1)
+	else
+		VIDEO_GID=$(stat -c '%g' /dev/dvb/* | grep -v '^0$' | head -n 1)
+	fi
+	# just add abc to root if stuff in dri/dvb is root owned
+	if [ -z "${VIDEO_GID}" ]; then
+		usermod -a -G root abc
+		exit 0
+	fi
+else
+	exit 0
+fi
+
+# Check if this GID matches the current abc user
+ABCGID=$(getent group abc | awk -F: '{print $3}')
+if [ "${ABCGID}" == "${VIDEO_GID}" ]; then
+	exit 0
+fi
+
+# Check if the GID is taken and swap to 65533
+CURRENT=$(getent group ${VIDEO_GID} | awk -F: '{print $1}')
+if [ -z "${CURRENT}" ] || [ "${CURRENT}" == 'video' ]; then
+	groupmod -g ${VIDEO_GID} video
+	usermod -a -G video abc
+else
+	groupmod -g 65533 ${CURRENT}
+	groupmod -g ${VIDEO_GID} video
+	usermod -a -G video abc
+fi