Skip to content

Commit ef7d8a6

Browse files
authored
Merge pull request #306 from linuxserver/videofix
increase video perm fix verbosity, set group rw
2 parents 194fe90 + 561f735 commit ef7d8a6

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
299299

300300
## Versions
301301

302+
* **04.03.22:** - Increase verbosity of video device permissions fix, attempt to fix missing group rw.
302303
* **25.12.21:** - Install Intel drivers from the official repo.
303304
* **20.01.21:** - Deprecate `UMASK_SET` in favor of UMASK in baseimage, see above for more information.
304305
* **10.12.20:** - Add latest Intel Compute packages from github repo for opencl support on latest gen igpu.

readme-vars.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ app_setup_block: |
107107
108108
# changelog
109109
changelogs:
110+
- { date: "04.03.22:", desc: "Increase verbosity of video device permissions fix, attempt to fix missing group rw." }
110111
- { date: "25.12.21:", desc: "Install Intel drivers from the official repo." }
111112
- { date: "20.01.21:", desc: "Deprecate `UMASK_SET` in favor of UMASK in baseimage, see above for more information." }
112113
- { date: "10.12.20:", desc: "Add latest Intel Compute packages from github repo for opencl support on latest gen igpu." }

root/etc/cont-init.d/50-gid-video

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,32 @@ FILES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null)
44

55
for i in $FILES
66
do
7-
VIDEO_GID=$(stat -c '%g' "$i")
8-
if ! id -G abc | grep -qw "$VIDEO_GID"; then
9-
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
10-
if [ -z "${VIDEO_NAME}" ]; then
11-
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c8)"
12-
groupadd "$VIDEO_NAME"
13-
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
7+
VIDEO_GID=$(stat -c '%g' "${i}")
8+
VIDEO_UID=$(stat -c '%u' "${i}")
9+
# check if user matches device
10+
if id -u abc | grep -qw "${VIDEO_UID}"; then
11+
echo "**** permissions for ${i} are good ****"
12+
else
13+
# check if group matches and that device has group rw
14+
if id -G abc | grep -qw "${VIDEO_GID}" && [ $(stat -c '%A' "${i}" | cut -b 5,6) = "rw" ]; then
15+
echo "**** permissions for ${i} are good ****"
16+
# check if device needs to be added to video group
17+
elif ! id -G abc | grep -qw "${VIDEO_GID}"; then
18+
# check if video group needs to be created
19+
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
20+
if [ -z "${VIDEO_NAME}" ]; then
21+
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-z0-9' | head -c4)"
22+
groupadd "${VIDEO_NAME}"
23+
groupmod -g "${VIDEO_GID}" "${VIDEO_NAME}"
24+
echo "**** creating video group ${VIDEO_NAME} with id ${VIDEO_GID} ****"
25+
fi
26+
echo "**** adding ${i} to video group ${VIDEO_NAME} with id ${VIDEO_GID} ****"
27+
usermod -a -G "${VIDEO_NAME}" abc
1428
fi
15-
usermod -a -G "$VIDEO_NAME" abc
29+
# check if device has group rw
1630
if [ $(stat -c '%A' "${i}" | cut -b 5,6) != "rw" ]; then
17-
echo -e "**** The device ${i} does not have group read/write permissions, which might prevent hardware transcode from functioning correctly. To fix it, you can run the following on your docker host: ****\nsudo chmod g+rw ${i}\n"
31+
echo -e "**** The device ${i} does not have group read/write permissions, attempting to fix inside the container. ****"
32+
chmod g+rw "${i}"
1833
fi
1934
fi
2035
done

0 commit comments

Comments
 (0)