Scripts to make it easier to use MullvadVPN on Gentoo
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
481 B

#! /bin/bash
#
# SPDX-License-Identifier: BlueOak-1.0.0
#
# Copyright (c) 2021 Gavin D. Howard.
#
set -e
country=$(cat "%%COUNTRY_FILE%%")
opts=$(find "%%CONFIG_DIR%%" -name "mullvad-$country*" | sort)
num=$(find "%%CONFIG_DIR%%" -name "mullvad-$country*" | wc -l)
idx=$(printf 'irand(%s) + 1\n' "$num" | bc)
i=0
for f in $opts; do
if [ "$i" = "$idx" ]; then
conn_file="$f"
break
fi
i=$(printf '%s + 1\n' "$i" | bc)
done
exec wg-quick up "$conn_file" > /dev/null