#!/bin/bash
# postinst script for bluetooth-sensor-scanner

set -e

case "$1" in
    configure)
        # Make the script executable
        chmod +x /usr/bin/ws-bluetooth-devices
        chmod +x /usr/bin/ws-bluetooth-unique-count
        
        # Enable the timer using deb-systemd-helper
        deb-systemd-helper unmask ws-bluetooth-scanner.timer >/dev/null || true
        deb-systemd-helper enable ws-bluetooth-scanner.timer >/dev/null || true
        deb-systemd-invoke start ws-bluetooth-scanner.timer >/dev/null || true
        
        echo "Bluetooth scanner timer has been enabled and started."
        echo "It will run every minute. Check status with:"
        echo "  systemctl status ws-bluetooth-scanner.timer"
        echo "  systemctl list-timers ws-bluetooth-scanner.timer"
        echo ""
        echo "Log files will be created in /var/log/bluetooth-scanner/"
        ;;
    
    abort-upgrade|abort-remove|abort-deconfigure)
        ;;
    
    *)
        echo "postinst called with unknown argument \`$1'" >&2
        exit 1
        ;;
esac

#DEBHELPER#

exit 0
