diff --git a/README.md b/README.md index e80ddec8..6e307aa4 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/readme-vars.yml b/readme-vars.yml index 6cf57ab4..47025c6f 100644 --- a/readme-vars.yml +++ b/readme-vars.yml @@ -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: @@ -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."} diff --git a/root/etc/s6-overlay/s6-rc.d/init-jellyfin-video/run b/root/etc/s6-overlay/s6-rc.d/init-jellyfin-video/run index c7654615..d62bc5ef 100755 --- a/root/etc/s6-overlay/s6-rc.d/init-jellyfin-video/run +++ b/root/etc/s6-overlay/s6-rc.d/init-jellyfin-video/run @@ -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