#!/usr/bin/env bash
# sudo apt install -y kodi

# 18.04  bionic     buster
# 17.10  artful     stretch

URL=ppa.launchpadcontent.net
RELEASE=kinetic	
APP=mkusb
PPA_KEY="54B8C8AC"
VERSION=unstable  # ppa
packages="
	mkusb \
	mkusb-nox \
	usb-pack-efi \
	dus \
	guidus \
	fdisk \
	"

# wget -O - https://${URL}/${APP}/openwebrx-plus.gpg | gpg --dearmor -o /etc/apt/trusted.gpg.d/openwebrx-plus.gpg

echo "deb http:/${URL}/${APP}/${VERSION}/ubuntu ${RELEASE} main" > sudo tee -a /etc/apt/sources.list-available/mkusb-ppa.list
echo "deb-src http://${URL}/${APP}/${VERSION}/ubuntu ${RELEASE} main" >> sudo tee -a /etc/apt/sources.list-available/mkusb-ppa.list

sudo ln -sf /etc/apt/sources.list-available/mkusb-ppa.list /etc/apt/sources.list.d/mkusb-ppa.list

# Bypass apt-proxy for mkusb packages
if [ -d /etc/apt/apt.conf.d/02proxy ]; then
	if [ "$(grep -q ${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-key export ${PPA_KEY} | sudo gpg --dearmour -o /etc/apt/trusted.gpg.d/${APP}.gpg

sudo apt update

sudo apt install -y --no-install-recommends "$packages" 
