From b193f31874d56c2c2b1bf2f22ff7f42d1944d3b3 Mon Sep 17 00:00:00 2001 From: Keith Irwin Date: Sat, 10 Sep 2022 15:09:39 -0600 Subject: [PATCH] Final fix for that hopefully --- back/lib/http_res | 5 +++-- back/srv/dashboard/add | 2 -- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/back/lib/http_res b/back/lib/http_res index 25c87ce..9746592 100755 --- a/back/lib/http_res +++ b/back/lib/http_res @@ -3,8 +3,8 @@ # DESCRIPTION: Formats an http response from arguments # USAGE: [printf "message" |] res [200] [text/plain] +# Accept stdin as body body="$(cat)" -printf "${*}\n${body}" >>"${LOGFILE}" # Parse status status='' @@ -13,11 +13,12 @@ case "${1}" in '201') status='Status: 201 Created\n';; '202') status='Status: 202 Accepted\n';; '400') status='Status: 400 Bad Request\n';; + '409') status='Status: 409 Conflict\n';; '500') status='Status: 500 Internal Server Error\n';; *) exit 3;; esac -# Parse inputs +# Parse content-type content_type='' if [ "${2}" == '' ] && [ "${body}" == '' ] then content_type='' diff --git a/back/srv/dashboard/add b/back/srv/dashboard/add index aba26a3..3548c9b 100755 --- a/back/srv/dashboard/add +++ b/back/srv/dashboard/add @@ -59,11 +59,9 @@ domain="${hostname}.${username}.${TLD}" # Check if new peer already exists if "${LIB_DIR}/ns_lookup_send" "${domain}" >/dev/null; then - set -x printf '%s.%s.%s already exists!\n' "${hostname}" "${username}" "${TLD}" >>"${LOGFILE}" printf 'Hostname %s already exists!\n' "${hostname}" | "${LIB_DIR}/http_res" 409 exit 6 - set +x fi # Create new domain