Skip to content

Instantly share code, notes, and snippets.

@learnitall
Created January 29, 2024 15:48
Show Gist options
  • Save learnitall/33696e413a3e46e5b9d8861feab7e8c8 to your computer and use it in GitHub Desktop.
Save learnitall/33696e413a3e46e5b9d8861feab7e8c8 to your computer and use it in GitHub Desktop.
import-windscribe.fish
#!/usr/bin/env fish
# Import .ovpn from Windscribe using NetworkManager
set -l target $argv[1]
set -l creds $argv[2]
echo Importing $target using $creds
set -l con_name (basename -s .ovpn $target)
set -l username (cat $creds | head -n 1)
set -l password (cat $creds | tail -n 1)
if nmcli -g name con show | grep $con_name > /dev/null;
echo "Con already exists"
nmcli -g name,uuid con show | grep $con_name
exit 1
end
set -l fish_trace on
nmcli con import type openvpn file $target
nmcli con mod $con_name +vpn.data username=$username
nmcli con mod $con_name +vpn.data password-flags=0
nmcli con mod $con_name vpn.secrets password=$password
set -u fish_trace
nmcli -g name,uuid con show | grep $con_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment