12 lines
415 B
Bash
Executable File
12 lines
415 B
Bash
Executable File
#!/bin/bash
|
|
# FILE: wagon:back/lib/wg/peer/add
|
|
# DESCRIPTION: Add a new peer to a wireguard interface
|
|
# USAGE: add pubkey psk allowedips
|
|
|
|
source /etc/wagon/config
|
|
pubkey="${1}"; psk="${2}"; allowedips="${3}"
|
|
|
|
if ! res="$(printf '%s\n' "${psk}" | sudo /usr/bin/wg set "${TLD}" peer "${pubkey}" preshared-key /dev/stdin allowed-ips "${allowedips}")"; then
|
|
printf '%s %s\n' "${?}" "${res}" >&2
|
|
exit 1
|
|
fi |