docker-plex-wireguard/root/etc/cont-init.d/50-gid-video

21 lines
855 B
Text
Raw Normal View History

#!/usr/bin/with-contenv bash
2019-09-18 17:27:28 -07:00
FILES=$(find /dev/dri /dev/dvb -type c -print 2>/dev/null)
2019-09-17 12:55:06 -04:00
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"
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"
fi
fi
2019-09-18 11:32:00 -04:00
done