Skip to content

Commit 7dca33c

Browse files
committed
increase verbosity of init-video
1 parent a0fc72b commit 7dca33c

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
371371

372372
## Versions
373373

374-
* **12.02.24:** - Use universal hardware acceleration blurb
374+
* **01.05.24:** - Increase verbosity of device permissions fixing.
375+
* **12.02.24:** - Use universal hardware acceleration blurb.
375376
* **12.09.23:** - Take ownership of plugin directories.
376377
* **04.07.23:** - Deprecate armhf. As announced [here](https://www.linuxserver.io/blog/a-farewell-to-arm-hf)
377378
* **07.12.22:** - Rebase master to Jammy, migrate to s6v3.

readme-vars.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ readme_hwaccel: true
104104
unraid_template_sync: false
105105
# changelog
106106
changelogs:
107-
- {date: "12.02.24:", desc: "Use universal hardware acceleration blurb"}
107+
- {date: "01.05.24:", desc: "Increase verbosity of device permissions fixing."}
108+
- {date: "12.02.24:", desc: "Use universal hardware acceleration blurb."}
108109
- {date: "12.09.23:", desc: "Take ownership of plugin directories."}
109110
- {date: "04.07.23:", desc: "Deprecate armhf. As announced [here](https://www.linuxserver.io/blog/a-farewell-to-arm-hf)"}
110111
- {date: "07.12.22:", desc: "Rebase master to Jammy, migrate to s6v3."}

root/etc/s6-overlay/s6-rc.d/init-jellyfin-video/run

+26-12
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,33 @@
33

44
FILES=$(find /dev/dri /dev/dvb /dev/vchiq /dev/vc-mem /dev/video1? -type c -print 2>/dev/null)
55

6-
for i in $FILES
7-
do
8-
VIDEO_GID=$(stat -c '%g' "$i")
9-
if ! id -G abc | grep -qw "$VIDEO_GID"; then
10-
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
11-
if [[ -z "${VIDEO_NAME}" ]]; then
12-
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c8)"
13-
groupadd "$VIDEO_NAME"
14-
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
6+
for i in ${FILES}; do
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
1528
fi
16-
usermod -a -G "$VIDEO_NAME" abc
17-
if [ $(stat -c '%A' "${i}" | cut -b 5,6) != "rw" ]; then
18-
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"
29+
# check if device has group rw
30+
if [[ $(stat -c '%A' "${i}" | cut -b 5,6) != "rw" ]]; then
31+
echo -e "**** The device ${i} does not have group read/write permissions, attempting to fix inside the container. ****"
32+
chmod g+rw "${i}"
1933
fi
2034
fi
2135
done

0 commit comments

Comments
 (0)