fix: add root detection for setcap and rfkill commands in CI
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 <noreply@anthropic.com>
This commit is contained in:
parent
9410630561
commit
eebdeb3907
1 changed files with 12 additions and 2 deletions
14
install.sh
14
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue