Add udev to container
This commit is contained in:
@@ -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:04 am
|
||||
# Last Modified: Friday, 14th January 2022 8:53:16 am
|
||||
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||
###
|
||||
|
||||
@@ -124,7 +124,6 @@ docker run -d --name="${container_name}" \
|
||||
-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} \
|
||||
|
||||
41
overlay/etc/cont-init.d/30-configure_udev.sh
Normal file
41
overlay/etc/cont-init.d/30-configure_udev.sh
Normal file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
###
|
||||
# File: 30-configure_udev.sh
|
||||
# Project: cont-init.d
|
||||
# File Created: Friday, 12th January 2022 8:54:01 am
|
||||
# Author: Josh.5 (jsunnex@gmail.com)
|
||||
# -----
|
||||
# Last Modified: Friday, 14th January 2022 9:21:11 am
|
||||
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||
###
|
||||
|
||||
# Running udev only works in privileged container
|
||||
# Source: https://github.com/balena-io-playground/balena-base-images/
|
||||
tmp_mount='/tmp/privileged_test'
|
||||
mkdir -p "${tmp_mount}"
|
||||
if mount -t devtmpfs none "${tmp_mount}" &> /dev/null; then
|
||||
is_privileged=true
|
||||
umount "${tmp_mount}"
|
||||
else
|
||||
is_privileged=false
|
||||
fi
|
||||
rm -rf "${tmp_mount}"
|
||||
|
||||
|
||||
if [[ "${is_privileged}" == "true" ]]; then
|
||||
echo "**** Configure container to run udev management ****";
|
||||
# Enable supervisord script
|
||||
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor/conf.d/udev.conf
|
||||
# Make startup script executable
|
||||
chmod +x /usr/bin/start-udev.sh
|
||||
# Configure udev permissions
|
||||
sed -i 's/MODE="0660"/MODE="0666"/' /lib/udev/rules.d/60-steam-input.rules
|
||||
else
|
||||
# Disable supervisord script
|
||||
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor/conf.d/udev.conf
|
||||
fi
|
||||
|
||||
|
||||
echo "**** Ensure the default user has the correct permissions on input devices ****";
|
||||
chmod +x /usr/bin/ensure-groups
|
||||
/usr/bin/ensure-groups /dev/uinput /dev/input/event*
|
||||
11
overlay/etc/supervisor/conf.d/udev.conf
Normal file
11
overlay/etc/supervisor/conf.d/udev.conf
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
[program:udev]
|
||||
autostart=false
|
||||
priority=10
|
||||
directory=/
|
||||
command=/usr/bin/start-udev.sh
|
||||
user=root
|
||||
autorestart=true
|
||||
stopsignal=QUIT
|
||||
stdout_logfile=/var/log/supervisor/udev.log
|
||||
stderr_logfile=/var/log/supervisor/udev.err
|
||||
23
overlay/usr/bin/start-udev.sh
Normal file
23
overlay/usr/bin/start-udev.sh
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
###
|
||||
# File: start-xorg.sh
|
||||
# Project: bin
|
||||
# File Created: Tuesday, 12th January 2022 8:46:47 am
|
||||
# Author: Josh.5 (jsunnex@gmail.com)
|
||||
# -----
|
||||
# Last Modified: Friday, 14th January 2022 9:21:00 am
|
||||
# Modified By: Josh.5 (jsunnex@gmail.com)
|
||||
###
|
||||
|
||||
# Start udev
|
||||
# Source: https://github.com/balena-io-playground/balena-base-images/
|
||||
if command -v udevd &> /dev/null; then
|
||||
unshare --net udevd --daemon &> /dev/null
|
||||
else
|
||||
unshare --net /lib/systemd/systemd-udevd --daemon &> /dev/null
|
||||
fi
|
||||
udevadm trigger &> /dev/null
|
||||
|
||||
|
||||
# Monitry kernel uevents
|
||||
udevadm monitor
|
||||
Reference in New Issue
Block a user