20 lines
477 B
Bash
Executable File
20 lines
477 B
Bash
Executable File
#!/bin/bash
|
|
# FILE: wgapi:back/lib/wg/peer/del
|
|
# DESCRIPTION: Delete a peer from a wireguard interface
|
|
# USAGE: del pubkey
|
|
# ERRORS:
|
|
# 3: Bad usage
|
|
# 4: wg binary not found
|
|
# 5: config not found
|
|
# 6: wg command failed
|
|
# 7: Not root
|
|
|
|
CONFIG_FILE='/etc/wgapi/config'
|
|
[ "$#" == "3" ] || exit 3
|
|
[ -x /usr/bin/wg ] || exit 4
|
|
(( EUID == 0 )) || exit 7
|
|
[ -f "${CONFIG_FILE}" ] || exit 5
|
|
source "${CONFIG_FILE}"
|
|
|
|
/usr/bin/wg set "${TLD}" peer "${1}" remove || exit 6
|