Skip to content

Commit

Permalink
Merge pull request #243 from linuxserver/init-video
Browse files Browse the repository at this point in the history
increase verbosity of init-video
  • Loading branch information
aptalca authored May 3, 2024
2 parents a0fc72b + 6b5e610 commit b595c34
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 16 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64

## Versions

* **12.02.24:** - Use universal hardware acceleration blurb
* **01.05.24:** - Increase verbosity of device permissions fixing.
* **12.02.24:** - Use universal hardware acceleration blurb.
* **12.09.23:** - Take ownership of plugin directories.
* **04.07.23:** - Deprecate armhf. As announced [here](https://www.linuxserver.io/blog/a-farewell-to-arm-hf)
* **07.12.22:** - Rebase master to Jammy, migrate to s6v3.
Expand Down
5 changes: 2 additions & 3 deletions readme-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ param_usage_include_ports: true
param_ports:
- {external_port: "8096", internal_port: "8096", port_desc: "Http webUI."}
param_usage_include_env: true
param_env_vars:
- {env_var: "TZ", env_value: "Europe/London", desc: "Specify a timezone to use (e.g. Europe/London)."}
# optional container parameters
opt_param_usage_include_env: true
opt_param_env_vars:
Expand Down Expand Up @@ -104,7 +102,8 @@ readme_hwaccel: true
unraid_template_sync: false
# changelog
changelogs:
- {date: "12.02.24:", desc: "Use universal hardware acceleration blurb"}
- {date: "01.05.24:", desc: "Increase verbosity of device permissions fixing."}
- {date: "12.02.24:", desc: "Use universal hardware acceleration blurb."}
- {date: "12.09.23:", desc: "Take ownership of plugin directories."}
- {date: "04.07.23:", desc: "Deprecate armhf. As announced [here](https://www.linuxserver.io/blog/a-farewell-to-arm-hf)"}
- {date: "07.12.22:", desc: "Rebase master to Jammy, migrate to s6v3."}
Expand Down
38 changes: 26 additions & 12 deletions root/etc/s6-overlay/s6-rc.d/init-jellyfin-video/run
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,33 @@

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

for i in $FILES
do
VIDEO_GID=$(stat -c '%g' "$i")
if ! id -G abc | grep -qw "$VIDEO_GID"; then
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
if [[ -z "${VIDEO_NAME}" ]]; then
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c8)"
groupadd "$VIDEO_NAME"
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
for i in ${FILES}; do
VIDEO_GID=$(stat -c '%g' "${i}")
VIDEO_UID=$(stat -c '%u' "${i}")
# check if user matches device
if id -u abc | grep -qw "${VIDEO_UID}"; then
echo "**** permissions for ${i} are good ****"
else
# check if group matches and that device has group rw
if id -G abc | grep -qw "${VIDEO_GID}" && [[ $(stat -c '%A' "${i}" | cut -b 5,6) == "rw" ]]; then
echo "**** permissions for ${i} are good ****"
# check if device needs to be added to video group
elif ! id -G abc | grep -qw "${VIDEO_GID}"; then
# check if video group needs to be created
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
if [[ -z "${VIDEO_NAME}" ]]; then
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-z0-9' | head -c4)"
groupadd "${VIDEO_NAME}"
groupmod -g "${VIDEO_GID}" "${VIDEO_NAME}"
echo "**** creating video group ${VIDEO_NAME} with id ${VIDEO_GID} ****"
fi
echo "**** adding ${i} to video group ${VIDEO_NAME} with id ${VIDEO_GID} ****"
usermod -a -G "${VIDEO_NAME}" abc
fi
usermod -a -G "$VIDEO_NAME" abc
if [ $(stat -c '%A' "${i}" | cut -b 5,6) != "rw" ]; then
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"
# check if device has group rw
if [[ $(stat -c '%A' "${i}" | cut -b 5,6) != "rw" ]]; then
echo -e "**** The device ${i} does not have group read/write permissions, attempting to fix inside the container. ****"
chmod g+rw "${i}"
fi
fi
done
Expand Down

0 comments on commit b595c34

Please sign in to comment.