Hello xmlrpc to another function!

This commit is contained in:
Ermal 2010-12-10 00:19:22 +00:00
parent 68ef6e03bd
commit e501de37f7
3 changed files with 37 additions and 2 deletions

View File

@ -760,11 +760,25 @@ function check_firmware_version($tocheck = "all", $return_php = true) {
return $versions;
}
/*
* host_firmware_version(): Return the versions used in this install
*/
function host_firmware_version() {
global $g, $config;
return array(
"firmware" => array("version" => trim(file_get_contents('/etc/version', " \n"))),
"kernel" => array("version" => trim(file_get_contents('/etc/version_kernel', " \n"))),
"base" => array("version" => trim(file_get_contents('/etc/version_base', " \n"))),
"platform" => trim(file_get_contents('/etc/platform', " \n")),
"config_version" => $config['version']
);
}
function get_disk_info() {
$diskout = "";
exec("/bin/df -h | /usr/bin/grep -w '/' | /usr/bin/awk '{ print $2, $3, $4, $5 }'", $diskout);
return explode(' ', $diskout[0]);
// $size, $used, $avail, $cap
}
/****f* pfsense-utils/strncpy

View File

@ -88,7 +88,7 @@ function remove_special_characters($string) {
return $string;
}
function carp_check_version($url, $password, $port = 80, $method = 'pfsense.check_firmware_version') {
function carp_check_version($url, $password, $port = 80, $method = 'pfsense.host_firmware_version') {
global $config, $g;
if(file_exists("{$g['varrun_path']}/booting") || $g['booting'])

View File

@ -301,6 +301,24 @@ function check_firmware_version_xmlrpc($raw_params) {
return new XML_RPC_Response(new XML_RPC_Value(check_firmware_version(false), $XML_RPC_String));
}
/*****************************/
$pfsense_firmware_version_doc = gettext("Basic XMLRPC wrapper for check_firmware_version. This function will return the output of check_firmware_version upon co
mpletion.");
$pfsense_firmware_version_sig = array(
$XML_RPC_String,
);
function pfsense_firmware_version_xmlrpc($raw_params) {
global $xmlrpc_g, $XML_RPC_String;
$params = xmlrpc_params_to_php($raw_params);
if(!xmlrpc_auth($params))
return $xmlrpc_g['return']['authfail'];
return new XML_RPC_Response(new XML_RPC_Value(host_firmware_version(), $XML_RPC_String));
}
/*****************************/
$reboot_doc = gettext("Basic XMLRPC wrapper for rc.reboot.");
$reboot_sig = array(array($XML_RPC_Boolean, $XML_RPC_String));
@ -371,6 +389,9 @@ $server = new XML_RPC_Server(
'pfsense.check_firmware_version' => array('function' => 'check_firmware_version_xmlrpc',
'signature' => $check_firmware_version_sig,
'docstring' => $check_firmware_version_doc),
'pfsense.host_firmware_version' => array('function' => 'pfsense_firmware_version_xmlrpc',
'signature' => $host_firmware_version_sig,
'docstring' => $host_firmware_version_doc),
'pfsense.reboot' => array('function' => 'reboot_xmlrpc',
'signature' => $reboot_sig,
'docstring' => $reboot_doc),