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

26 lines
662 B

#!/usr/bin/with-contenv bash
# Check for the existence of the Intel video device
if [ -e /dev/dri ]; then
VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1)
else
exit 0
fi
# Check if this GID matches the current abc user
ABCGID=$(getent group abc | awk -F: '{print $3}')
if [ "${ABCGID}" == "${VIDEO_GID}" ]; then
exit 0
fi
# Check if the GID is taken and swap to 65533
CURRENT=$(getent group ${VIDEO_GID} | awk -F: '{print $1}')
if [ -z "${CURRENT}" ] || [ "${CURRENT}" == 'video' ]; then
groupmod -g ${VIDEO_GID} video
usermod -a -G video abc
else
groupmod -g 65533 ${CURRENT}
groupmod -g ${VIDEO_GID} video
usermod -a -G video abc
fi