Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Logic to cleanup created device #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions down.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,25 @@
#! /bin/bash
echo "Tearing down mullvad-proxy containers..."
echo "Getting account info and wireguard key..."
docker exec -it mvpn mullvad account get

# Get all account & devices
account="$(docker exec -it mvpn mullvad account get)"
devices="$(docker exec --tty mvpn mullvad account list-devices | tail -n +2)"

echo $account
docker exec -it mvpn mullvad tunnel get
docker compose down --volumes --remove-orphans
echo "Remember to delete the above Wireguard keys from the account to free them up."

# loop till we get this device
while IFS= read -r device; do
# echo "device $device"
found="$(echo "$account" | grep "$device")"
if [ -n "$found" ]; then
deviceStr="$(echo "${device//[$'\t\r\n']/}")"
echo "Removing device '$deviceStr'"
# remove device
docker exec --tty mvpn mullvad account revoke-device "$deviceStr"

fi
done <<<"$devices"

docker compose down --volumes --remove-orphans