apatel762 / dotfiles

Managing the /home directory on my machines
GNU Affero General Public License v3.0
0 stars 0 forks source link

setup mullvad #9

Closed apatel762 closed 5 months ago

apatel762 commented 5 months ago

WireGuard

installing mullvad via the .rpm file didn't work for whatever reason, so i want to find a way to manage the vpn connection via wireguard directly (using the config file generator that Mullvad provides)

apatel762 commented 5 months ago

transferred the issue here from the workstation repo (big jump!)

my idea so far is to keep the wireguard configuration file (managed by chezmoi) somewhere in my home directory, and create a script that can be used to load that configuration file as a new network manager vpn connection config

something like

~/.local/share/chezmoi/home/.chezmoiscripts/run_after_apply.sh

#!/usr/bin/env bash

if [ "$#" -ne 1 ]; then
    echo "Usage: $0 <wireguard-config-file>"
    exit 1
fi

CONFIG_FILE=$1
INTERFACE=$(basename "$CONFIG_FILE" .conf)

if nmcli connection show | grep -q "$INTERFACE"; then
    echo "Connection for $INTERFACE already exists. Exiting."
    exit 0
fi

nmcli connection import type wireguard file "$CONFIG_FILE"

# Verify the connection was added successfully
if nmcli connection show | grep -q "$INTERFACE"; then
    echo "WireGuard VPN configuration for $INTERFACE added successfully."
else
    echo "Failed to add WireGuard VPN configuration for $INTERFACE."
    exit 1
fi
apatel762 commented 5 months ago

fixed by e827a53bfe163ef38402cd5de555d46472f5f9f9