20 lines
491 B
Bash
Executable File
20 lines
491 B
Bash
Executable File
#!/bin/bash
|
|
# FILE: wagon:back/lib/wg_peer_del
|
|
# DESCRIPTION: Delete a peer from a wireguard interface
|
|
# USAGE: wg_peer_del pubkey
|
|
|
|
source /etc/wagon/config
|
|
pubkey="${1}"
|
|
|
|
# Delete peer from interface
|
|
if ! res_int="$(sudo /usr/bin/wg set "${TLD}" peer "${pubkey}" remove)"; then
|
|
printf 'ERROR! Wireguard failed: %s\n' "${res_int}" >&2
|
|
exit 1
|
|
fi &
|
|
|
|
# Save config
|
|
if ! res_conf="$(sudo /usr/bin/wg-quick save ${TLD})"; then
|
|
printf '%s %s\n' "${?}" "${res_conf}" >&2
|
|
exit 1
|
|
fi
|