diff --git a/modules/mullvad/mullvad.sh b/modules/mullvad/mullvad.sh index 934d3cb..37ec422 100755 --- a/modules/mullvad/mullvad.sh +++ b/modules/mullvad/mullvad.sh @@ -25,16 +25,16 @@ cmd() { sudo "$@" } -# Make sure gpg-agent is unlocked so the period where the interface exists but -# no private key is set is minised. -pass web/mullvad.net/wireguard >/dev/null - for interface in /sys/class/net/*; do interface="${interface#/sys/class/net/}" [[ $interface =~ ^mullvad-(v6-)?[a-z]{2}[0-9]*$ ]] && cmd wg-quick down "$interface" done if [ "$1" != "off" ]; then + # Make sure gpg-agent is unlocked so the period where the interface exists but + # no private key is set is minised. + pass web/mullvad.net/wireguard >/dev/null + cmd wg-quick up "$INTERFACE" pass web/mullvad.net/wireguard | while read -r line; do key="${line%%: *}"