You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
10
-
if [ -z "${VIDEO_NAME}" ]; then
11
-
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-zA-Z0-9' | head -c8)"
12
-
groupadd "$VIDEO_NAME"
13
-
groupmod -g "$VIDEO_GID" "$VIDEO_NAME"
7
+
VIDEO_GID=$(stat -c '%g' "${i}")
8
+
VIDEO_UID=$(stat -c '%u' "${i}")
9
+
# check if user matches device
10
+
if id -u abc | grep -qw "${VIDEO_UID}"; then
11
+
echo "**** permissions for ${i} are good ****"
12
+
else
13
+
# check if group matches and that device has group rw
14
+
if id -G abc | grep -qw "${VIDEO_GID}" && [ $(stat -c '%A' "${i}" | cut -b 5,6) = "rw" ]; then
15
+
echo "**** permissions for ${i} are good ****"
16
+
# check if device needs to be added to video group
17
+
elif ! id -G abc | grep -qw "${VIDEO_GID}"; then
18
+
# check if video group needs to be created
19
+
VIDEO_NAME=$(getent group "${VIDEO_GID}" | awk -F: '{print $1}')
20
+
if [ -z "${VIDEO_NAME}" ]; then
21
+
VIDEO_NAME="video$(head /dev/urandom | tr -dc 'a-z0-9' | head -c4)"
22
+
groupadd "${VIDEO_NAME}"
23
+
groupmod -g "${VIDEO_GID}" "${VIDEO_NAME}"
24
+
echo "**** creating video group ${VIDEO_NAME} with id ${VIDEO_GID} ****"
25
+
fi
26
+
echo "**** adding ${i} to video group ${VIDEO_NAME} with id ${VIDEO_GID} ****"
27
+
usermod -a -G "${VIDEO_NAME}" abc
14
28
fi
15
-
usermod -a -G "$VIDEO_NAME" abc
29
+
# check if device has group rw
16
30
if [ $(stat -c '%A' "${i}" | cut -b 5,6) != "rw" ]; then
17
-
echo -e "**** The device ${i} does not have group read/write permissions, which might prevent hardware transcode from functioning correctly. To fix it, you can run the following on your docker host: ****\nsudo chmod g+rw ${i}\n"
31
+
echo -e "**** The device ${i} does not have group read/write permissions, attempting to fix inside the container. ****"
0 commit comments