You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
docker-plex/root/etc/cont-init.d/50-gid-video

37 lines
827 B

#!/usr/bin/with-contenv bash
# check for the existence of a video and/or tuner device
if [ -e /dev/dri ] || [ -e /dev/dvb ]; then
if [ -e /dev/dri ]; then
FILES="${FILES} /dev/dri/*"
fi
if [ -e /dev/dvb ]; then
FILES="${FILES} /dev/dvb/*"
fi
else
exit 0
fi
for i in $FILES
do
VIDEO_GID=$(stat -c '%g' "$i")
if id -G abc | grep -qw "$VIDEO_GID"; then
touch /groupadd
else
if [ ! "${VIDEO_GID}" == '0' ]; 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
touch /groupadd
fi
fi
done
if [ ! -z "${FILES}" ] && [ ! -f "/groupadd" ]; then
usermod -a -G root abc
fi