From d313045996f55605771ff27b6fe49059074c40e3 Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Sun, 15 Mar 2020 22:17:32 -0400 Subject: [PATCH] Create 81-enable-hw.bash --- root/etc/cont-init.d/81-enable-hw.bash | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 root/etc/cont-init.d/81-enable-hw.bash diff --git a/root/etc/cont-init.d/81-enable-hw.bash b/root/etc/cont-init.d/81-enable-hw.bash new file mode 100644 index 0000000..2a76e77 --- /dev/null +++ b/root/etc/cont-init.d/81-enable-hw.bash @@ -0,0 +1,26 @@ +#!/usr/bin/with-contenv bash + +## hardware support ## +FILES=$(find /dev/dri -type c -print 2>/dev/null) +for i in $FILES +do + VIDEO_GID=$(stat -c '%g' "$i") + if id -G abc | grep -qw "$VIDEO_GID"; then + touch /groupadd + else + if [ ! "${VIDEO_GID}" == '0' ]; then + 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)" + groupadd "$VIDEO_NAME" + groupmod -g "$VIDEO_GID" "$VIDEO_NAME" + fi + usermod -a -G "$VIDEO_NAME" abc + touch /groupadd + fi + fi +done +if [ -n "${FILES}" ] && [ ! -f "/groupadd" ]; then + usermod -a -G root abc +fi +exit 0