add abc to all video and render groups
This commit is contained in:
parent
f22dc94338
commit
66046f9582
1 changed files with 20 additions and 23 deletions
|
|
@ -3,32 +3,29 @@
|
||||||
# check for the existence of a video and/or tuner device
|
# check for the existence of a video and/or tuner device
|
||||||
if [ -e /dev/dri ] || [ -e /dev/dvb ]; then
|
if [ -e /dev/dri ] || [ -e /dev/dvb ]; then
|
||||||
if [ -e /dev/dri ]; then
|
if [ -e /dev/dri ]; then
|
||||||
VIDEO_GID=$(stat -c '%g' /dev/dri/* | grep -v '^0$' | head -n 1)
|
FILES="${FILES} /dev/dri/*"
|
||||||
else
|
|
||||||
VIDEO_GID=$(stat -c '%g' /dev/dvb/* | grep -v '^0$' | head -n 1)
|
|
||||||
fi
|
fi
|
||||||
# just add abc to root if stuff in dri/dvb is root owned
|
if [ -e /dev/dvb ]; then
|
||||||
if [ -z "${VIDEO_GID}" ]; 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
|
||||||
|
if [ "${VIDEO_GID}" == '0' ]; then
|
||||||
usermod -a -G root abc
|
usermod -a -G root abc
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
exit 0
|
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
|
||||||
|
if [ -z "${VIDEO_NAME}" ]; then
|
||||||
|
VIDEO_NAME="video$(head /dev/urandom | tr -dc 0-9 | head -c4)"
|
||||||
|
groupadd "$VIDEO_NAME"
|
||||||
|
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
|
||||||
fi
|
fi
|
||||||
|
usermod -a -G "$VIDEO_NAME" abc
|
||||||
# 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
|
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
|
fi
|
||||||
|
done
|
||||||
Loading…
Add table
Add a link
Reference in a new issue