Final fix for that hopefully
parent
131a60349c
commit
b193f31874
|
@ -3,8 +3,8 @@
|
||||||
# DESCRIPTION: Formats an http response from arguments
|
# DESCRIPTION: Formats an http response from arguments
|
||||||
# USAGE: [printf "message" |] res [200] [text/plain]
|
# USAGE: [printf "message" |] res [200] [text/plain]
|
||||||
|
|
||||||
|
# Accept stdin as body
|
||||||
body="$(cat)"
|
body="$(cat)"
|
||||||
printf "${*}\n${body}" >>"${LOGFILE}"
|
|
||||||
|
|
||||||
# Parse status
|
# Parse status
|
||||||
status=''
|
status=''
|
||||||
|
@ -13,11 +13,12 @@ case "${1}" in
|
||||||
'201') status='Status: 201 Created\n';;
|
'201') status='Status: 201 Created\n';;
|
||||||
'202') status='Status: 202 Accepted\n';;
|
'202') status='Status: 202 Accepted\n';;
|
||||||
'400') status='Status: 400 Bad Request\n';;
|
'400') status='Status: 400 Bad Request\n';;
|
||||||
|
'409') status='Status: 409 Conflict\n';;
|
||||||
'500') status='Status: 500 Internal Server Error\n';;
|
'500') status='Status: 500 Internal Server Error\n';;
|
||||||
*) exit 3;;
|
*) exit 3;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# Parse inputs
|
# Parse content-type
|
||||||
content_type=''
|
content_type=''
|
||||||
if [ "${2}" == '' ] && [ "${body}" == '' ]
|
if [ "${2}" == '' ] && [ "${body}" == '' ]
|
||||||
then content_type=''
|
then content_type=''
|
||||||
|
|
|
@ -59,11 +59,9 @@ domain="${hostname}.${username}.${TLD}"
|
||||||
|
|
||||||
# Check if new peer already exists
|
# Check if new peer already exists
|
||||||
if "${LIB_DIR}/ns_lookup_send" "${domain}" >/dev/null; then
|
if "${LIB_DIR}/ns_lookup_send" "${domain}" >/dev/null; then
|
||||||
set -x
|
|
||||||
printf '%s.%s.%s already exists!\n' "${hostname}" "${username}" "${TLD}" >>"${LOGFILE}"
|
printf '%s.%s.%s already exists!\n' "${hostname}" "${username}" "${TLD}" >>"${LOGFILE}"
|
||||||
printf 'Hostname %s already exists!\n' "${hostname}" | "${LIB_DIR}/http_res" 409
|
printf 'Hostname %s already exists!\n' "${hostname}" | "${LIB_DIR}/http_res" 409
|
||||||
exit 6
|
exit 6
|
||||||
set +x
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create new domain
|
# Create new domain
|
||||||
|
|
Loading…
Reference in New Issue