From de54096f147a0a8974c340adcf56f66098aee0a0 Mon Sep 17 00:00:00 2001 From: Infinidoge Date: Thu, 10 Jul 2025 14:32:32 -0400 Subject: [PATCH] bin/addtovpn: init --- bin/addtovpn.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 bin/addtovpn.sh diff --git a/bin/addtovpn.sh b/bin/addtovpn.sh new file mode 100755 index 0000000..ffc32d4 --- /dev/null +++ b/bin/addtovpn.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +name=$1 +number=$2 +address="192.168.200.$number/32" + +private=$(wg genkey) +public=$(echo "$private" | wg pubkey) +psk=$(wg genpsk) + +cat << EOF > /tmp/$name.conf +[Interface] +Address = $address +PrivateKey = $private +DNS = 1.1.1.1 + +[Peer] +PublicKey = $(cat /etc/secrets/wireguard/public) +PresharedKey = $psk +Endpoint = vpn.inx.moe:51820 +AllowedIPs = 0.0.0.0/0 +EOF + +cat << EOF >> /tmp/wireguard-config.nix +{ + name = "$name"; + publicKey = "$public"; + presharedKey = "$psk"; + allowedIPs = ip $number; +} +EOF