#!/bin/sh
# Debian postinst: give the binary CAP_NET_RAW (raw HCI socket for the passive
# BLE scan) and CAP_NET_ADMIN (WiFi scan trigger) so the GUI never runs as root.
# A filesystem without extended attributes keeps the package installable: the
# app then reports "permission denied" in its BLE status line.
set -e

case "$1" in
    configure)
        if command -v setcap >/dev/null 2>&1; then
            setcap cap_net_raw,cap_net_admin+eip /usr/bin/rfguard 2>/dev/null || \
                echo "rfguard: setcap failed, BLE scanning will need root" >&2
        fi
        ;;
esac

exit 0
