#!/bin/bash
set -euxo pipefail

DEB="anydesk_arm64.deb"

if [[ ! -f "$DEB" ]]; then
    echo "postinst: bundled $DEB not found in $(pwd)" >&2
    exit 1
fi

if [[ $EUID -ne 0 ]]; then
    echo "postinst: must run as root (uid=$EUID)" >&2
    exit 1
fi

export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install -y --no-install-recommends "./$DEB"

systemctl enable --now anydesk

anydesk --version || true

echo "postinst: anydesk installed"
