fix http syntax

This commit is contained in:
Hackintosh Five 2023-08-09 10:34:42 +01:00
parent 661ddd13c0
commit 48c45e8742

View File

@ -1,4 +1,10 @@
#!/bin/bash #!/bin/bash
respond () {
DATE="$(LC_ALL=C date -u '+%a, %d %b %Y %H:%M:%S GMT')"
printf "%s $1\r\nDate: $DATE\r\nContent-Length: 0\r\nConnection: close\r\nContent-Type: application/octet-stream\r\n\r\n" "${start_line[2]}"
}
read -r -a start_line read -r -a start_line
start_line[2]="${start_line[2]%$'\r'}" start_line[2]="${start_line[2]%$'\r'}"
case "${start_line[2]}" in case "${start_line[2]}" in
@ -8,25 +14,31 @@ case "${start_line[2]}" in
case "${start_line[1]}" in case "${start_line[1]}" in
"/healthz/startupProbe") "/healthz/startupProbe")
if pidof -q openconnect && pidof -q tcpproxy; then if pidof -q openconnect && pidof -q tcpproxy; then
printf "%s 200 OK\r\n" "${start_line[2]}" respond "200 OK"
# printf "%s 200 OK\r\n" "${start_line[2]}"
else else
printf "%s 503 Service Unavailable\r\n" "${start_line[2]}" respond "503 Service Unavailable"
# printf "%s 503 Service Unavailable\r\n" "${start_line[2]}"
fi fi
;; ;;
"/healthz/livenessProbe" | "/healthz/readinessProbe") "/healthz/livenessProbe" | "/healthz/readinessProbe")
if pidof -q openconnect && pidof -q tcpproxy && cmp <(ncat localhost 1234 -c "/usr/bin/printf '\x30\x0c\x02\x01\x01\x60\x07\x02\x01\x03\x04\x00\x80\x00'; timeout --preserve-status 1 cat >&2" 2>&1) <(printf "\x30\x0c\x02\x01\x01\x61\x07\x0a\x01\x00\x04\x00\x04\x00"); then if pidof -q openconnect && pidof -q tcpproxy && cmp <(ncat localhost 1234 -c "/usr/bin/printf '\x30\x0c\x02\x01\x01\x60\x07\x02\x01\x03\x04\x00\x80\x00'; timeout --preserve-status 1 cat >&2" 2>&1) <(printf "\x30\x0c\x02\x01\x01\x61\x07\x0a\x01\x00\x04\x00\x04\x00"); then
printf "%s 200 OK\r\n" "${start_line[2]}" respond "200 OK"
# printf "%s 200 OK\r\n" "${start_line[2]}"
else else
printf "%s 503 Service Unavailable\r\n" "${start_line[2]}" respond "503 Service Unavailable"
# printf "%s 503 Service Unavailable\r\n" "${start_line[2]}"
fi fi
;; ;;
*) *)
printf "%s 404 Not Found\r\n" "${start_line[2]}" respond "404 Not Found"
# printf "%s 404 Not Found\r\n" "${start_line[2]}"
;; ;;
esac esac
;; ;;
*) *)
printf "%s 405 Method Not Allowed\r\n" "${start_line[2]}" respond "405 Method Not Allowed"
# printf "%s 405 Method Not Allowed\r\n" "${start_line[2]}"
;; ;;
esac esac
;; ;;