bin/addtovpn: init

This commit is contained in:
Infinidoge 2025-07-10 14:32:32 -04:00
parent 7c79b16e22
commit de54096f14
Signed by: Infinidoge
SSH key fingerprint: SHA256:EMoPe5e2dO0gEvtBb2xkZTz5dkyL0rBmuiGTKG5s96E

31
bin/addtovpn.sh Executable file
View file

@ -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