#!/bin/bash

MACHINE_TYPE=""
if [ -e /etc/astra/machine_type ]; then
    MACHINE_TYPE=`cat /etc/astra/machine_type | head -1 | tr -s ' '`
    echo "astra-mobile: detected machine type $MACHINE_TYPE"
fi

if [ "$MACHINE_TYPE" == 'MIGT8X.amd64.v2.rev50' ]; then
    # This device does not have a bluetooth module.
    exit 0
fi

case "$1" in
pre)
    /usr/sbin/bluetooth_devices_reconnect $1
    ;;
post)
    systemd-run --system --scope /usr/sbin/bluetooth_devices_reconnect $1 &
    ;;
esac

exit 0
