mirror of
https://github.com/flynx/proxmox-utils.git
synced 2025-10-31 20:20:08 +00:00
25 lines
496 B
Bash
Executable File
25 lines
496 B
Bash
Executable File
#!/usr/bin/bash
|
|
|
|
SERVER_TEMPLATE=${SERVER_TEMPLATE:=templates/wg0.conf}
|
|
SERVER_CONF=/etc/wireguard/wg0.conf
|
|
|
|
PUBLIC_KEY=/etc/wireguard/server_id
|
|
PRIVATE_KEY=/etc/wireguard/server_id.pub
|
|
|
|
|
|
if ! [ -e "$PRIVATE_KEY" ] ; then
|
|
wg genkey > "$PRIVATE_KEY"
|
|
fi
|
|
if ! [ -e "$PUBLIC_KEY" ] ; then
|
|
cat "$PRIVATE_KEY" | wg pubkey > "$PUBLIC_KEY"
|
|
fi
|
|
|
|
PRIVATE_KEY=$(cat "$PRIVATE_KEY")
|
|
cat ${SERVER_TEMPLATE} \
|
|
| sed \
|
|
-q 's/\${SERVER_PRIVATE_KEY}/'${PRIVATE_KEY}'/g' \
|
|
> "${SERVER_CONF}"
|
|
|
|
./make-client
|
|
|