34 lines
918 B
Text
Executable file
34 lines
918 B
Text
Executable file
#!/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
|
|
VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1)
|
|
else
|
|
VIDEO_GID=$(stat -c '%g' /dev/dvb/* | grep -v '^0$' | head -n 1)
|
|
fi
|
|
# just add abc to root if stuff in dri/dvb is root owned
|
|
if [ -z "${VIDEO_GID}" ]; then
|
|
usermod -a -G root abc
|
|
exit 0
|
|
fi
|
|
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
|