#!/usr/bin/env bash

[[ "$EUID" -ne 0 ]] && exec sudo -s "$0" "$@"

ver=$(</etc/debian_version)

apt update
apt -y install ca-certificates apt-transport-https
if [[ ${ver%.*} -ge 12 ]]; then
    apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 112695A0E562B32A 54404762BBB6E853
    echo 'deb http://security.debian.org/debian-security bullseye-security main' > /etc/apt/sources.list.d/deb11.list
fi
wget -qO - https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > /etc/apt/trusted.gpg.d/microsoft.asc.gpg
wget -qO - https://repo.netpolice.ru/astralinux/repo_gpg.key | gpg --dearmor > /etc/apt/trusted.gpg.d/netpolice.asc.gpg
wget -qO /etc/apt/sources.list.d/microsoft.list https://packages.microsoft.com/config/debian/11/prod.list
wget -qO /etc/apt/sources.list.d/netpolice.list https://repo.netpolice.ru/astralinux/netpolice.list
apt update
apt -y install netpolicelinux

sudo -k
