#!/usr/bin/env bash

URL=riot.im
RELEASE=buster


sudo sh -c "echo 'deb https://${URL}.im/packages/debian/ ${RELEASE} main' > /etc/apt/sources.list-available/matrix-riot-im.list"

sudo ln -s /etc/apt/sources.list-available/matrix-riot-im.list /etc/apt/sources.list.d/matrix-riot-im.list

# Add the public key:
KEY_DIR=/etc/apt/keyrings
curl -L https://riot.im/packages/debian/repo-key.asc | sudo tee ${KEY_DIR}/riotIM.asc

# Bypass apt-proxy for riotIM packages
if [ -d /etc/apt/apt.conf.d/02proxy ]; then
	if [ ! -z $(grep "${URL}") ]; then
		echo "Acquire::http::Proxy { \"${URL}\" DIRECT; };" >> /etc/apt/apt.conf.d/02proxy
	fi
else
		echo "Acquire::http::Proxy { \"${URL}\" DIRECT; };" >> /etc/apt/apt.conf.d/02proxy
fi

sudo apt update && apt install -y riot-web


