40 lines
1.5 KiB
Bash
40 lines
1.5 KiB
Bash
#!/usr/bin/env bash
|
|
# One-time root setup for the Siri Remote test host (Fedora/Debian).
|
|
# Run: sudo bash setup-host.sh <user>
|
|
set -euo pipefail
|
|
USER_NAME="${1:-${SUDO_USER:-}}"
|
|
[ -n "$USER_NAME" ] || { echo "usage: sudo bash $0 <user>"; exit 1; }
|
|
|
|
echo "== packages"
|
|
if command -v dnf >/dev/null; then
|
|
dnf install -y evtest hid-tools bluez bluez-tools || dnf install -y evtest bluez
|
|
elif command -v apt-get >/dev/null; then
|
|
apt-get install -y evtest bluez python3-hid-tools || apt-get install -y evtest bluez
|
|
fi
|
|
|
|
echo "== unblock bluetooth (persistent)"
|
|
rfkill unblock bluetooth
|
|
systemctl enable --now bluetooth
|
|
# Keep the adapter on after reboot.
|
|
sed -i 's/^#\?AutoEnable=.*/AutoEnable=true/' /etc/bluetooth/main.conf || true
|
|
|
|
echo "== device access for group 'smartfox'"
|
|
groupadd -f smartfox
|
|
usermod -aG smartfox,input "$USER_NAME"
|
|
cat >/etc/udev/rules.d/70-smartfox.rules <<'EOF'
|
|
# SmartFox: remote daemon reads raw HID and writes virtual key events.
|
|
KERNEL=="hidraw*", SUBSYSTEM=="hidraw", GROUP="smartfox", MODE="0660"
|
|
KERNEL=="uinput", SUBSYSTEM=="misc", GROUP="smartfox", MODE="0660", OPTIONS+="static_node=uinput"
|
|
EOF
|
|
modprobe uinput || true
|
|
udevadm control --reload-rules
|
|
udevadm trigger --subsystem-match=hidraw --subsystem-match=misc
|
|
|
|
# Read-only debugging without a password: btmon capture.
|
|
cat >/etc/sudoers.d/smartfox-btmon <<EOF
|
|
$USER_NAME ALL=(root) NOPASSWD: /usr/bin/btmon
|
|
EOF
|
|
chmod 440 /etc/sudoers.d/smartfox-btmon
|
|
|
|
echo "== done. Log out and back in (or reconnect ssh) for the new groups."
|