Update post handler to use less env-vars.

This commit is contained in:
Koray Yanik 2022-03-24 00:16:47 +00:00
parent 2d8c9989ae
commit 3a359ebe28

View File

@ -6,10 +6,10 @@ if [[ "$REQUEST_PATH_SANE" =~ ^refresh ]]; then
body="{\n\"time\": \"$(date +%T)\",\n"
body+="\"status\": \"ok\"\n}\n"
header=$($BASHSERV_DIR/header.sh -t "application/json" -l $(echo -ne "$body" | wc -c))
printf "%b\n%b" "$header" "$body"
$BASHSERV_DIR/header.sh -t "application/json" -l $(echo -ne "$body" | wc -c)
printf "%b" "$body"
echo -ne "$body" > status/$ip
printf "%b" "$body" > status/$ip
ret=1
for i in {0..30}; do
@ -34,10 +34,8 @@ if [[ "$REQUEST_PATH_SANE" =~ ^wol ]]; then
wol "$mac" > /dev/null
body="{\"response\": \"ok\"}\n"
cat <<EOF
$($BASHSERV_DIR/header.sh -t "application/json" -l $(echo -ne "$body" | wc -c))
$(echo -ne $body)
EOF
$BASHSERV_DIR/header.sh -t "application/json" -l $(echo -ne "$body" | wc -c)
printf "%b" "$body"
exit 0
fi