From f3a0f9be473338868ff88009c36a10bf112c19e1 Mon Sep 17 00:00:00 2001 From: john30 Date: Sun, 5 Mar 2017 13:09:53 +0100 Subject: [PATCH] endpoint for update check --- contrib/updatecheck/calcversions.sh | 5 ++++ contrib/updatecheck/index.php | 39 +++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 contrib/updatecheck/calcversions.sh create mode 100644 contrib/updatecheck/index.php diff --git a/contrib/updatecheck/calcversions.sh b/contrib/updatecheck/calcversions.sh new file mode 100644 index 00000000..6640a651 --- /dev/null +++ b/contrib/updatecheck/calcversions.sh @@ -0,0 +1,5 @@ +#!/bin/sh +version=`head -n 1 VERSION` +revision=`git describe --always` +echo "ebusd=${version}.${revision}" +#TODO add calculation for config files diff --git a/contrib/updatecheck/index.php b/contrib/updatecheck/index.php new file mode 100644 index 00000000..337db8e1 --- /dev/null +++ b/contrib/updatecheck/index.php @@ -0,0 +1,39 @@ +1) { + $versions[$val[0]] = explode(',', $val[1]); + } + }; + array_walk($v, $func); + } + header('Content-Type: text/plain'); + $ret = 'unknown'; + $r = @json_decode($r, true); + if (!$r || !isset($r['v'])) { + $ret = 'invalid request'; + } else { + if (isset($versions['ebusd'])) { + if ($r['v']==$versions['ebusd'][0]) { + $ret = 'OK'; + } else { + $ret = 'ebusd '.$versions['ebusd'][0].' available'; + } + } + // TODO add check for config files + } + echo $ret; + exit; +} +header('HTTP/1.1 404 Not Found'); +?>