Created
July 29, 2024 16:04
-
-
Save stevecrozz/fd91035fb3133c385dab8825ec219baa to your computer and use it in GitHub Desktop.
Process mullvad ini config into some edgerouter config
This file contains hidden or 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 | |
| private_key=$(grep PrivateKey "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}') | |
| public_key=$(grep PublicKey "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}') | |
| allowed_ips=$(grep AllowedIPs "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}') | |
| address=$(grep Address "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}') | |
| endpoint=$(grep Endpoint "$1" | cut -d ' ' -f 3 | awk '{$1=$1;print}') | |
| echo $private_key | |
| echo $public_key | |
| echo $allowed_ips | cut -d ',' -f 1 | |
| echo $allowed_ips | cut -d ',' -f 2 | |
| ipv4address=$(echo $address | cut -d ',' -f 1) | |
| ipv6address=$(echo $address | cut -d ',' -f 2) | |
| echo $endpoint | |
| cat << EOF | |
| delete interfaces wireguard wg1 address | |
| delete interfaces wireguard wg1 peer | |
| set interfaces wireguard wg1 address $ipv4address | |
| set interfaces wireguard wg1 address $ipv6address | |
| set interfaces wireguard wg1 peer $public_key | |
| set interfaces wireguard wg1 peer $public_key allowed-ips 0.0.0.0/0 | |
| set interfaces wireguard wg1 peer $public_key allowed-ips ::0/0 | |
| set interfaces wireguard wg1 peer $public_key endpoint $endpoint | |
| set interfaces wireguard wg1 private-key $private_key | |
| EOF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment