diff --git a/bashserv b/bashserv
index 99fcf7a..ef70aa4 160000
--- a/bashserv
+++ b/bashserv
@@ -1 +1 @@
-Subproject commit 99fcf7aa5be5210c082dd9c483717e1fb1204f93
+Subproject commit ef70aa40f9be1b8006f8ec1d9cbf17f93f722f1d
diff --git a/handle_get.sh b/handle_get.sh
index 7c48d54..5f050d7 100755
--- a/handle_get.sh
+++ b/handle_get.sh
@@ -7,6 +7,7 @@ if [ $? -eq 0 ]; then
exit 0
fi
+set $REQUEST_FIELDS
while [[ $# -gt 0 ]]; do
length="$1"
key="$2"
@@ -29,7 +30,9 @@ while [[ $# -gt 0 ]]; do
done
if [ -z "$REQUEST_PATH_SANE" -o "$REQUEST_PATH_SANE" == "index.html" ]; then
- body="\n
\n$WAKEBOARD_TITLE\n\n"
+ body="\n\n$WAKEBOARD_TITLE\n"
+ body+="\n"
+
if [ $mobile ]; then
body+="\n\n"
else
@@ -57,7 +60,7 @@ if [ -z "$REQUEST_PATH_SANE" -o "$REQUEST_PATH_SANE" == "index.html" ]; then
body+="$hostname | "
body+="$ip | "
body+="$mac | "
- body+=" | \n"
+ body+=" | | \n"
body+=""
fi
done
diff --git a/handle_post.sh b/handle_post.sh
new file mode 100755
index 0000000..e89d154
--- /dev/null
+++ b/handle_post.sh
@@ -0,0 +1,47 @@
+#!/bin/bash
+
+if [[ "$REQUEST_PATH_SANE" =~ ^refresh ]]; then
+ ip=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2)
+
+ body="{\n\"time\": \"$(date +%T)\",\n"
+ body+="\"status\": \"unknown\"\n}\n"
+
+cat < status/$ip
+
+ ret=1
+ for i in {0..30}; do
+ ping -c 1 -w 5 -t 1 -q "$ip" > /dev/null 2>&1
+ ret=$?
+ [ $ret -eq 0 ] && break
+ done
+
+ echo -e "{\n\"time\": \"$(date +%T)\"," > status/$ip
+
+ if [ $ret -eq 0 ]; then
+ echo -e "\"status\": \"up\"\n}\n" >> status/$ip
+ else
+ echo -e "\"status\": \"down\"\n}\n" >> status/$ip
+ fi
+ exit 0
+fi
+
+if [[ "$REQUEST_PATH_SANE" =~ ^wol ]]; then
+ mac=$(echo "$POST_DATA" | cut -d '=' -f2)
+
+ wol "$mac" > /dev/null
+ body="{\"response\": \"ok\"}\n"
+
+cat < /dev/null 2>&1
ret=$?
[ $ret -eq 0 ] && break
done
@@ -46,18 +46,4 @@ EOF
exit 0
fi
-if [[ "$REQUEST_PATH_SANE" =~ ^wol ]]; then
- mac=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2)
-
- wol "$mac" > /dev/null
- body="{\"response\": \"ok\"}\n"
-
-cat < |