mirror of
https://github.com/unraid/webgui.git
synced 2026-04-22 18:19:14 -05:00
Use 'emcmd' that POSTs to /update endpoint.
This commit is contained in:
@@ -19,11 +19,12 @@ function curl_socket($socket, $url, $postdata = NULL)
|
||||
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
|
||||
}
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
||||
curl_exec($ch);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
}
|
||||
function publish($endpoint, $message)
|
||||
{
|
||||
curl_socket("/var/run/nginx.socket", "http://localhost/pub/$endpoint?buffer_length=1", $message);
|
||||
return curl_socket("/var/run/nginx.socket", "http://localhost/pub/$endpoint?buffer_length=1", $message);
|
||||
}
|
||||
?>
|
||||
|
||||
Executable
+14
@@ -0,0 +1,14 @@
|
||||
#!/usr/bin/php
|
||||
<?PHP
|
||||
require_once "/usr/local/emhttp/webGui/include/publish.php";
|
||||
function emhttp_command($cmd)
|
||||
{
|
||||
$var = parse_ini_file("/var/local/emhttp/var.ini");
|
||||
$cmd .= "&csrf_token={$var['csrf_token']}";
|
||||
return curl_socket("/var/run/emhttpd.socket", "http://localhost/update", $cmd);
|
||||
}
|
||||
$result = emhttp_command($argv[1]);
|
||||
if ($result === "") exit(0);
|
||||
echo "$result".PHP_EOL;
|
||||
exit(1);
|
||||
?>
|
||||
@@ -1,18 +0,0 @@
|
||||
#!/usr/bin/php -q
|
||||
<?PHP
|
||||
/* Copyright 2005-2018, Lime Technology
|
||||
* Copyright 2012-2018, Bergware International.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License version 2,
|
||||
* as published by the Free Software Foundation.
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*/
|
||||
?>
|
||||
<?
|
||||
$docroot = $docroot ?? $_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp';
|
||||
require_once "$docroot/webGui/include/publish.php";
|
||||
curl_socket("/var/run/emhttpd.socket", "http://localhost/status.htm");
|
||||
?>
|
||||
Reference in New Issue
Block a user