#!/bin/bash set -euo pipefail IFS=$'\n\t' if [[ $# -ne 1 ]]; then echo "Usage: $0 <wg server config file>" exit 1 fi [[ -a "$1" ]] && echo "File already exists. Nope." >&2 && exit 1 # create client keypair srv_privkey=$(wg genkey) srv_pubkey=$(wg pubkey <<< "$srv_privkey") umask 177 cat >> "$1" <<EOF [Interface] PrivateKey = $srv_privkey Address = TODO ListenPort = TODO Table = off # Pubkey = $srv_pubkey EOF