From eebdeb3907b1a74d7f9a10a9e28266fc87169dbf Mon Sep 17 00:00:00 2001 From: torlando-tech Date: Wed, 29 Oct 2025 10:02:51 -0400 Subject: [PATCH] fix: add root detection for setcap and rfkill commands in CI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The installer was failing in CI Docker containers with "sudo: command not found" because Docker containers run as root and don't have sudo installed. Added root detection (checking $EUID) before setcap and rfkill commands, following the same pattern used elsewhere in the script. This allows the installer to work correctly in both scenarios: - User systems: Uses sudo when needed (non-root users) - Docker/CI containers: Runs commands directly as root (no sudo required) Fixes the CI failure at install.sh:458 where setcap was unconditionally using sudo, and prevents future failures at the rfkill command. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- install.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/install.sh b/install.sh index a43459c..e2823cb 100755 --- a/install.sh +++ b/install.sh @@ -455,7 +455,12 @@ else # Grant capabilities if we have a valid path if [ -f "$PYTHON_PATH" ] && [ ! -L "$PYTHON_PATH" ]; then print_info "Granting capabilities to: $PYTHON_PATH" - sudo setcap 'cap_net_raw,cap_net_admin+eip' "$PYTHON_PATH" + # Use sudo only if not running as root (Docker containers run as root without sudo) + if [ "$EUID" -eq 0 ]; then + setcap 'cap_net_raw,cap_net_admin+eip' "$PYTHON_PATH" + else + sudo setcap 'cap_net_raw,cap_net_admin+eip' "$PYTHON_PATH" + fi if [ $? -eq 0 ]; then print_success "Bluetooth permissions granted successfully" @@ -629,7 +634,12 @@ if command -v bluetoothctl &> /dev/null; then if rfkill list bluetooth | grep -q "Soft blocked: yes"; then print_warning "Bluetooth adapter is soft-blocked by rfkill" print_info "Unblocking Bluetooth adapter..." - sudo rfkill unblock bluetooth + # Use sudo only if not running as root (Docker containers run as root without sudo) + if [ "$EUID" -eq 0 ]; then + rfkill unblock bluetooth + else + sudo rfkill unblock bluetooth + fi sleep 1 # Verify unblock succeeded