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