unix mode

This commit is contained in:
john30
2017-03-05 13:14:38 +01:00
parent f3a0f9be47
commit 5a23e5c13a
2 changed files with 40 additions and 40 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
#!/bin/sh
version=`head -n 1 VERSION`
revision=`git describe --always`
echo "ebusd=${version}.${revision}"
echo "ebusd=${version}.${revision}" > versions.txt
#TODO add calculation for config files
+39 -39
View File
@@ -1,39 +1,39 @@
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (substr($agent, 0, 5)==='ebusd') {
$t = time();
$a = $_SERVER["REMOTE_ADDR"];
$r = @file_get_contents('php://input');
$v = @file_get_contents('versions.txt');
$versions = array();
if ($v) {
$v = explode("\n", $v);
$func = function($val, $k) {
global $versions;
$val = explode('=', $val);
if (count($val)>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');
?>
<?php
$agent = $_SERVER['HTTP_USER_AGENT'];
if (substr($agent, 0, 5)==='ebusd') {
$t = time();
$a = $_SERVER["REMOTE_ADDR"];
$r = @file_get_contents('php://input');
$v = @file_get_contents('versions.txt');
$versions = array();
if ($v) {
$v = explode("\n", $v);
$func = function($val, $k) {
global $versions;
$val = explode('=', $val);
if (count($val)>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');
?>