#!/usr/bin/env bash
#
# select and active wireguard interface; requires sudo

set -e

if [[ $EUID -gt 0 ]]; then
  echo "requires administrative privileges"
  exit 1
fi

defaultquery="es1"
conffile=$(find /etc/wireguard -type f -name '*.conf' | sort | fzf -q "$defaultquery")
config=$(basename "$conffile" ".conf")
wg-quick up "$config"