Created
May 12, 2022 08:06
-
-
Save Bapannarama/8839d9f1755012a93ab6c97a0e783030 to your computer and use it in GitHub Desktop.
Import mullvad wireguard profiles to networkmanager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
echo -n "VPN config files location (blank for current directory): " | |
read directory | |
if [[ $directory == '' ]] | |
then | |
directory="$PWD/*" | |
elif [[ ${directory: -2} == '/*' ]] | |
then | |
: | |
elif [[ ${directory: -1} == '/' ]] | |
then | |
directory="$directory*" | |
elif [[ ${directory: -1} != '/' ]] && [[ ${directory: -1} != '*' ]] | |
then | |
directory="$directory/*" | |
fi | |
for filename in $directory; do | |
echo "Adding profile for $filename" | |
nmcli connection import type wireguard file "$filename" | |
connection_name=$(basename $filename .conf) | |
nmcli connection down $connection_name | |
nmcli connection modify id $connection_name connection.autoconnect no | |
#nmcli connection delete $connection_name | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment