35 lines
1.3 KiB
Bash
35 lines
1.3 KiB
Bash
#!/bin/tcsh -f
|
|
echo -n "Enter a name for the wireguard config: "
|
|
set name = $<
|
|
echo -n "Enter the IP for this wireguard config: "
|
|
set ip = $<
|
|
echo -n "Enter the endpoint for this wireguard config: "
|
|
set endpoint = $<
|
|
echo -n "Enter the endpoint port for this wireguard config: "
|
|
set port = $<
|
|
echo -n "I will create a config with name $name and IP $ip. Is this correct? (y/n): "
|
|
set correct = $<
|
|
if ($correct == "y" || $correct == "Y") then
|
|
set wg_pubkey = `wg | grep public | cut -d " " -f5`
|
|
set conffile = "$name"_client.conf
|
|
set serverconf = "$name"_server.conf
|
|
set private = `wg genkey | tee "$name"_private.key`
|
|
set public = `wg pubkey < "$name"_private.key | tee "$name"_public.key`
|
|
set psk = `wg genpsk | tee "$name"_preshared.key`
|
|
# Client config file
|
|
echo "[Interface]" > $conffile
|
|
echo "PrivateKey = $private" >> $conffile
|
|
echo "Address = $ip/24" >> $conffile
|
|
echo "DNS = 31.182.126.198" >> $conffile
|
|
echo "" >> $conffile
|
|
echo "[Peer]" >> $conffile
|
|
echo "PublicKey = $wg_pubkey" >> $conffile
|
|
echo "PresharedKey = $psk" >> $conffile
|
|
echo "AllowedIPs = 0.0.0.0/0" >> $conffile
|
|
echo "Endpoint = ${endpoint}:${port}" >> $conffile
|
|
# Server config file
|
|
echo "[Peer]" > $serverconf
|
|
echo "AllowedIPs = $ip/32" >> $serverconf
|
|
echo "PreSharedKey = $psk" >> $serverconf
|
|
echo "Publickey = $public" >> $serverconf
|