diff --git a/README.md b/README.md index c3e1c77..ef54e18 100755 --- a/README.md +++ b/README.md @@ -154,7 +154,7 @@ services: - /dev:/dev:rw # Full /dev access improves hotplug handling - /run/udev:/run/udev:ro # Access to udev events environment: - + # - SKIP_PERMCHECK # Skip USB permission change for rootless implementations - SECRET_KEY=test1234567890 # for password encryption and decryption in the database - UDEV=1 # Improve USB detection ports: diff --git a/src/filesystem.sh b/src/filesystem.sh index 46a7c84..48d9863 100755 --- a/src/filesystem.sh +++ b/src/filesystem.sh @@ -116,21 +116,31 @@ detect_usb_devices() { # Function to fix USB permissions if applicable fix_usb_permissions() { - if [ -d "/dev/bus/usb" ]; then - # First set ownership to root:nut for good measure - chown -R root:nut /dev/bus/usb - # Now grant read-write to all users (old method that worked better) - chmod -R o+rw /dev/bus/usb 2>/dev/null - startup_log "USB device permissions updated (all users access granted)" - else - startup_log "WARNING: Directory /dev/bus/usb not found!" - fi - - # Set the suid bit on the nut commands - chmod u+s /usr/bin/upsc /usr/bin/upscmd /usr/bin/upsrw 2>/dev/null - if [ "$ENABLE_LOG_STARTUP" = "Y" ]; then - startup_log "Set suid permissions for NUT commands" - fi + case "${SKIP_PERMCHECK,,}" in + true|1|yes) + startup_log "Skipping USB permission updates (SKIP_PERMCHECK=${SKIP_PERMCHECK})" + if [ "$ENABLE_LOG_STARTUP" = "Y" ]; then + startup_log "Skipping SUID permissions for NUT commands (SKIP_PERMCHECK=${SKIP_PERMCHECK})" + fi + ;; + *) + if [ -d "/dev/bus/usb" ]; then + # First set ownership to root:nut for good measure + chown -R root:nut /dev/bus/usb + # Now grant read-write to all users (old method that worked better) + chmod -R o+rw /dev/bus/usb 2>/dev/null + startup_log "USB device permissions updated (all users access granted)" + else + startup_log "WARNING: Directory /dev/bus/usb not found!" + fi + + # Set the suid bit on the nut commands + chmod u+s /usr/bin/upsc /usr/bin/upscmd /usr/bin/upsrw 2>/dev/null + if [ "$ENABLE_LOG_STARTUP" = "Y" ]; then + startup_log "Set suid permissions for NUT commands" + fi + ;; + esac } # Clean up existing PID files to prevent conflicts