Added debugging
parent
28607db8d4
commit
72de903226
|
@ -10,19 +10,21 @@
|
|||
|
||||
CONFIG_FILE='/etc/wgapi/config'
|
||||
if ! [ ${#} -eq 3 ]; then
|
||||
printf '%s Bad usage: %s\n' "${0}" "${*}" >>"${LOGFILE}"
|
||||
printf 'ERROR! %s Bad usage: %s\n' "${0}" "${*}" >>"${LOGFILE}"
|
||||
exit 3
|
||||
fi & if [ -f "${CONFIG_FILE}" ]; then
|
||||
printf 'ERROR: %s could not find config at %s!\n' "${0}" "${CONFIG_FILE}" >>"${LOGFILE}"
|
||||
printf 'ERROR! %s could not find config at %s!\n' "${0}" "${CONFIG_FILE}" >>"${LOGFILE}"
|
||||
exit 4
|
||||
fi & if [ -x /usr/bin/wg ]; then
|
||||
printf 'ERROR: /usr/bin/wg not found\n' >>"${LOGFILE}"
|
||||
printf 'ERROR! /usr/bin/wg not found\n' >>"${LOGFILE}"
|
||||
exit 5
|
||||
fi; source "${CONFIG_FILE}"
|
||||
pubkey="${1}"
|
||||
psk="${2}"
|
||||
allowedips="${3}"
|
||||
|
||||
printf 'Adding %s %s %s %s\n' "${pubkey}" "${psk}" "${allowedips}" "${TLD}" >>"${LOGFILE}"
|
||||
|
||||
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}" >>"${LOGFILE}"
|
||||
exit 6
|
||||
|
|
Loading…
Reference in New Issue