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

27 lines
649 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")
2019-09-18 11:32:00 -04:00
if id -G abc | grep -qw "$VIDEO_GID"; then
touch /groupadd
else
if [ ! "${VIDEO_GID}" == '0' ]; then
2019-09-17 12:55:06 -04:00
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)"
2019-09-17 12:55:06 -04:00
groupadd "$VIDEO_NAME"
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
fi
usermod -a -G "$VIDEO_NAME" abc
2019-09-18 11:32:00 -04:00
touch /groupadd
2019-09-17 12:55:06 -04:00
fi
fi
2019-09-18 11:32:00 -04:00
done
2019-09-18 17:27:28 -07:00
if [ -n "${FILES}" ] && [ ! -f "/groupadd" ]; then
2019-09-18 11:32:00 -04:00
usermod -a -G root abc
fi