This commit is contained in:
ange 2025-07-21 13:08:28 +00:00
parent 17b03778ac
commit 5f1b118ff3
Signed by: ange
GPG key ID: 9E0C4157BB7BEB1D
26 changed files with 164 additions and 160 deletions

25
.local/bin/mullvad_update Executable file
View file

@ -0,0 +1,25 @@
#!/bin/bash -e
{ read -r AN; read -r PRV; } < <(pass mullvad | sed -n '1p; s/^Privkey:\s*//p')
ADDRESS="$(curl 'https://api.mullvad.net/wg/' \
-d "account=$AN" --data-urlencode "pubkey=$(wg pubkey <<< "$PRV")")"
j="$(curl 'https://api.mullvad.net/app/v1/relays/')"
q='.wireguard.relays[] | "\(.hostname) \(.ipv4_addr_in) \(.public_key)"'
DNS="$(jq -r '.wireguard.ipv4_gateway' <<< "$j")"
while read -r file endpoint pubkey; do
cat <<EOF > "$file.conf"
[Interface]
PrivateKey = $PRV
Address = $ADDRESS
DNS = $DNS
[Peer]
PublicKey = $pubkey
AllowedIPs = 0.0.0.0/0,::0/0
Endpoint = $endpoint:51820
EOF
done < <(jq -r "$q" <<< "$j")