diff --git a/devops/run_server.sh b/devops/run_server.sh index 9b27c17..08f89d4 100755 --- a/devops/run_server.sh +++ b/devops/run_server.sh @@ -5,7 +5,7 @@ # File Created: Saturday, 8th January 2022 2:34:23 pm # Author: Josh.5 (jsunnex@gmail.com) # ----- -# Last Modified: Friday, 14th January 2022 8:45:00 am +# Last Modified: Friday, 14th January 2022 8:45:04 am # Modified By: Josh.5 (jsunnex@gmail.com) ### @@ -123,6 +123,8 @@ docker run -d --name="${container_name}" \ -e ENABLE_VNC_AUDIO="false" \ -v "${project_base_path}/config/home/default-${container_name}":"/home/default":"rw" \ -v "/tmp/":"/tmp/":"rw" \ + -v /dev/input:/dev/input:ro \ + -v /run/udev:/run/udev:ro \ --hostname="${container_name}" \ --shm-size=2G \ ${additional_docker_params} \ diff --git a/overlay/etc/cont-init.d/41-configure-device-user-permision.sh b/overlay/etc/cont-init.d/41-configure-device-user-permision.sh new file mode 100644 index 0000000..6ff431e --- /dev/null +++ b/overlay/etc/cont-init.d/41-configure-device-user-permision.sh @@ -0,0 +1,15 @@ +#!/usr/bin/env bash +### +# File: configure-device-user-permision.sh +# Project: bin +# File Created: Thursday, 13th January 2022 10:30:36 pm +# Author: Josh.5 (jsunnex@gmail.com) +# ----- +# Last Modified: Thursday, 13th January 2022 10:37:28 pm +# Modified By: Josh.5 (jsunnex@gmail.com) +### + + +chmod +x /usr/bin/ensure-groups + +/usr/bin/ensure-groups /dev/uinput /dev/input/event* diff --git a/overlay/usr/bin/ensure-groups b/overlay/usr/bin/ensure-groups new file mode 100644 index 0000000..1bc2321 --- /dev/null +++ b/overlay/usr/bin/ensure-groups @@ -0,0 +1,45 @@ +#!/bin/bash + +# Source: https://github.com/games-on-whales/gow/ + +set -e + +function join_by { local IFS="$1"; shift; echo "$*"; } + +declare -A group_map + +for dev in "$@"; do + # Only process $dev if it's a character device + if [ ! -c "$dev" ]; then + continue + fi + + dev_group=$(stat -c "%G" "$dev") + dev_gid=$(stat -c "%g" "$dev") + + if [ "$dev_group" = "UNKNOWN" ]; then + new_name="user-gid-$dev_gid" + # We only have a GID for this group; create a named group for it + # this isn't 100% necessary but it prevents some useless noise in the console + groupadd -g $dev_gid "$new_name" + group_map[$new_name]=1 + else + # the group already exists; just add it to the list + group_map[$dev_group]=1 + fi +done + +# uinput is usually set to be read/write only by user root, we want to allow the group too +if [ -e /dev/uinput ]; then + echo "Allow /dev/uinput r/w to the group" + chmod 0660 /dev/uinput +fi + +groups=$(join_by "," "${!group_map[@]}") +if [ "$groups" != "" ]; then + echo "Adding user '${USER}' to groups: $groups" + + usermod -G $groups ${USER} +else + echo "Not modifying user groups ($groups)" +fi