Improved logging
parent
c4ff8ee734
commit
3160485a43
|
@ -25,8 +25,8 @@ CONFIG_FILE='/etc/wgapi/config'
|
|||
[ -f "${CONFIG_FILE}" ] || exit 5
|
||||
source "${CONFIG_FILE}"
|
||||
|
||||
res="$(/usr/bin/wg set "${TLD}" peer "${1}" preshared-key <(printf '%s' "${2}") allowed-ips "${3}")" || (
|
||||
res="$(sudo /usr/bin/wg set "${TLD}" peer "${1}" preshared-key <(printf '%s' "${2}") allowed-ips "${3}")" || (
|
||||
printf 'ERROR! wg failed to add peer for %s\n' "${3}" >>"${LOGFILE}"
|
||||
printf '%s' "${res}" >>"${LOGFILE}"
|
||||
printf '%s\n' "${res}" >>"${LOGFILE}"
|
||||
exit 6
|
||||
)
|
||||
|
|
|
@ -99,7 +99,7 @@ while IFS=$'\t' read -r server_hostname server_ipv4 server_ipv6 server_pubkey se
|
|||
server_blocks="${server_blocks}\n[Peer] # ${server_hostname}.${TLD}\nPublicKey=${server_pubkey}\nPresharedKey=${server_psk}\nAllowedIPs=${server_ipv4}/32,${server_ipv6}/128\nEndpoint=${server_endpoint}\n"
|
||||
if [ "${server_hostname}" == "${LOCAL_SERVER}" ]
|
||||
# Add new user to local server
|
||||
then printf 'Adding %s to local server...' "${domain}\n" >>"${LOGFILE}"
|
||||
then printf 'Adding %s to local server...\n' "${domain}" >>"${LOGFILE}"
|
||||
"${LIB_DIR}/wg_peer_add" "${pubkey}" "${server_psk}" "${ipv4}/32,${ipv6}/128" || (
|
||||
printf 'ERROR! Failed to add new peer %s to local server!\n' "${ipv4}" >>"${LOGFILE}"
|
||||
# TODO: clear existing progress and exit 15
|
||||
|
|
Loading…
Reference in New Issue