#!/bin/sh
pubkey=/tmp/archlinux.pub
curl -o $pubkey https://repo.snix.me/archlinux/archlinux.snix.gpg.pub -L -s
id=$(gpg --with-colons --import-options show-only --import < $pubkey | grep fpr | head -1 | cut -d: -f10)
pacman-key --list-keys "$id" >/dev/null 2>&1 || { pacman-key --add $pubkey && pacman-key --lsign-key "$id"; }
rm -f $pubkey
custom_repo=/etc/pacman.d/snix.conf
[ ! -f "$custom_repo" ] && echo "Include = $custom_repo" >> /etc/pacman.conf
cat > $custom_repo <<INNER
[snix]
SigLevel = PackageRequired
Server = https://repo.snix.me/archlinux/\$arch
INNER
