Update to how we choose if we are running udevd or dumb-udev
This fixes some issues I found with startup.
This commit is contained in:
@@ -9,50 +9,44 @@
|
||||
# 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
|
||||
# Since this container may also be run with CAP_SYS_ADMIN, ensure we can actually execute "udevadm trigger"
|
||||
if [ ! -w /sys ]; then
|
||||
# Disable supervisord script since we are not able to write to sysfs
|
||||
echo "**** Disable udev - /sys is mounted RO ****";
|
||||
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/udev.ini
|
||||
elif [ ! -w /run/udev ]; then
|
||||
# Disable supervisord script since we are not able to write to udev/data path
|
||||
echo "**** Disable udev - /run/udev is mounted RO ****";
|
||||
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/udev.ini
|
||||
elif udevadm trigger &> /dev/null; then
|
||||
echo "**** Configure container to run udev management ****";
|
||||
# Enable supervisord script
|
||||
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/udev.ini
|
||||
# Configure udev permissions
|
||||
if [[ -f /lib/udev/rules.d/60-steam-input.rules ]]; then
|
||||
sed -i 's/MODE="0660"/MODE="0666"/' /lib/udev/rules.d/60-steam-input.rules
|
||||
fi
|
||||
else
|
||||
# Disable supervisord script since we are not able to execute "udevadm trigger"
|
||||
echo "**** Disable udev service due to privilege restrictions ****";
|
||||
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/udev.ini
|
||||
fi
|
||||
else
|
||||
# Disable supervisord script
|
||||
echo "**** Disable udev service ****";
|
||||
# Since this container may also be run with CAP_SYS_ADMIN, ensure we can actually execute "udevadm trigger"
|
||||
run_dumb_udev="false"
|
||||
if [ ! -w /sys ]; then
|
||||
# Disable supervisord script since we are not able to write to sysfs
|
||||
echo "**** Disable udevd - /sys is mounted RO ****";
|
||||
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/udev.ini
|
||||
if [ ! -d /run/udev/data ]; then
|
||||
echo "**** Enable dumb-udev service ****";
|
||||
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/dumb-udev.ini
|
||||
run_dumb_udev="true"
|
||||
elif [ ! -d /run/udev ]; then
|
||||
# Disable supervisord script since we are not able to write to udev/data path
|
||||
echo "**** Disable udevd - /run/udev does not exist ****";
|
||||
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/udev.ini
|
||||
run_dumb_udev="true"
|
||||
elif [ ! -w /run/udev ]; then
|
||||
# Disable supervisord script since we are not able to write to udev/data path
|
||||
echo "**** Disable udevd - /run/udev is mounted RO ****";
|
||||
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/udev.ini
|
||||
run_dumb_udev="false"
|
||||
elif udevadm trigger &> /dev/null; then
|
||||
echo "**** Configure container to run udev management ****";
|
||||
# Enable supervisord script
|
||||
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/udev.ini
|
||||
# Configure udev permissions
|
||||
if [[ -f /lib/udev/rules.d/60-steam-input.rules ]]; then
|
||||
sed -i 's/MODE="0660"/MODE="0666"/' /lib/udev/rules.d/60-steam-input.rules
|
||||
fi
|
||||
run_dumb_udev="false"
|
||||
else
|
||||
# Disable supervisord script since we are not able to execute "udevadm trigger"
|
||||
echo "**** Disable udev service due to privilege restrictions ****";
|
||||
sed -i 's|^autostart.*=.*$|autostart=false|' /etc/supervisor.d/udev.ini
|
||||
run_dumb_udev="true"
|
||||
fi
|
||||
|
||||
if [ "${run_dumb_udev}" = "true" ]; then
|
||||
# Enable dumb-udev instead of udevd
|
||||
echo "**** Enable dumb-udev service ****";
|
||||
sed -i 's|^command.*=.*$|command=start-dumb-udev.sh|' /etc/supervisor.d/udev.ini
|
||||
sed -i 's|^autostart.*=.*$|autostart=true|' /etc/supervisor.d/udev.ini
|
||||
fi
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
|
||||
[program:udev]
|
||||
priority=10
|
||||
autostart=false
|
||||
autorestart=true
|
||||
user=root
|
||||
directory=/
|
||||
command=start-dumb-udev.sh
|
||||
stopsignal=INT
|
||||
stdout_logfile=/var/log/supervisor/dumb-udev.log
|
||||
stdout_logfile_maxbytes=10MB
|
||||
stdout_logfile_backups=7
|
||||
stderr_logfile=/var/log/supervisor/dumb-udev.err.log
|
||||
stderr_logfile_maxbytes=10MB
|
||||
stderr_logfile_backups=7
|
||||
Reference in New Issue
Block a user