Move refresh to a POST request
Technically it changes state...
This commit is contained in:
parent
3f6c392969
commit
1ec8fdc54e
@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "$REQUEST_PATH_SANE" =~ ^refresh ]]; then
|
||||
ip=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2)
|
||||
ip=$(echo "$POST_DATA" | cut -d '=' -f2)
|
||||
|
||||
body="{\n\"time\": \"$(date +%T)\",\n"
|
||||
body+="\"status\": \"unknown\"\n}\n"
|
||||
|
@ -1,35 +1,5 @@
|
||||
#!/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 <<EOF
|
||||
$($BASHSERV_DIR/header.sh -t "application/json" -l $(echo -ne "$body" | wc -c))
|
||||
$(echo -ne $body)
|
||||
EOF
|
||||
|
||||
echo -ne "$body" > 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" =~ ^status ]]; then
|
||||
ip=$(echo "$REQUEST_PATH_SANE" | cut -d '/' -f2)
|
||||
|
||||
|
@ -41,8 +41,10 @@ var request_refresh = function (host) {
|
||||
}
|
||||
});
|
||||
|
||||
request.open("GET", "refresh/" + host.ip);
|
||||
request.send();
|
||||
var params = "ip=" + host.ip;
|
||||
request.open("POST", "refresh", true);
|
||||
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
request.send(params);
|
||||
|
||||
setTimeout(function () {
|
||||
request_status(host);
|
||||
@ -70,7 +72,6 @@ var request_wol = function (host) {
|
||||
});
|
||||
|
||||
var params = "mac=" + host.mac;
|
||||
|
||||
request.open("POST", "wol", true);
|
||||
request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
|
||||
request.send(params);
|
||||
|
Loading…
Reference in New Issue
Block a user