Fixed hostname not set, make unset vars fail earlier

master
Keith Irwin 2022-09-11 18:00:00 -06:00
parent 99f270dbe9
commit 1027aa07ea
Signed by: ki9
GPG Key ID: DF773B3F4A88DA86
2 changed files with 6 additions and 5 deletions

View File

@ -135,13 +135,13 @@ for_server_do() {
}
# Update nameserver
if "${LIB_DIR}/ns_update_add" "${domain}" "${ipv4}" "${ipv6}"
if "${LIB_DIR}/ns_update_add" "${domain:?}" "${ipv4:?}" "${ipv6:?}"
then printf 'Successfully added %s to DNS server.\n' "${domain}" >>"${LOGFILE}"
else printf 'ERROR! Failed to add %s %s %s to DNS server!\n' "${domain}" "${ipv4}" "${ipv6}" >>"${LOGFILE}"
fi &
# Create SSL cert
if "${LIB_DIR}/ssl_peer_add" "${hostname}" "${username}" "IP:${ipv4},IP:${ipv6}"
if "${LIB_DIR}/ssl_peer_add" "${hostname:?}" "${username:?}" "IP:${ipv4},IP:${ipv6}"
then printf 'Successfully signed SSL certs for %s\n' "${domain}" >>"${LOGFILE}"
else printf 'ERROR! Failed to create certs for %s with IPS: %s %s!\n' "${domain}" "${ipv4}" "${ipv6}" >>"${LOGFILE}"
fi &

View File

@ -61,7 +61,8 @@ if ! printf 'Delete request was for %s %s %s\n' "${domain:?}" "${ipv4:?}" "${ipv
printf 'Failed to collect peer data\n' | "${LIB_DIR}/http_res" 500
exit 6
fi
hostname="$(<<<"${domain}" cut -d'.' -f1)" & username="$(<<<"${domain}" cut -d'.' -f2)"
hostname="$(<<<"${domain}" cut -d'.' -f1)"
username="$(<<<"${domain}" cut -d'.' -f2)"
# Wireguard
# Run this function in parallel in the while loop below
@ -97,13 +98,13 @@ for_server_do() {
done <"${SERVERS_FILE}" &
# Update nameserver
if "${LIB_DIR}/ns_update_del" "${domain}" "${ipv4}" "${ipv6}"
if "${LIB_DIR}/ns_update_del" "${domain:?}" "${ipv4:?}" "${ipv6:?}"
then printf 'Successfully deleted %s from DNS server.\n' "${domain}" >>"${LOGFILE}"
else printf 'ERROR! Failed to delete %s %s %s from DNS server!\n' "${domain}" "${ipv4}" "${ipv6}" >>"${LOGFILE}"
fi &
# Create SSL cert
if "${LIB_DIR}/ssl_peer_del" "${hostname}" "${username}"
if "${LIB_DIR}/ssl_peer_del" "${hostname:?}" "${username:?}"
then printf 'Successfully deleted SSL certs for %s\n' "${domain}" >>"${LOGFILE}"
else printf 'ERROR! Failed to delete certs for %s!\n' "${domain}" >>"${LOGFILE}"
fi