Revision c20a1eb2
Added by Colin Smith about 20 years ago
- Add get_disk_info().
- Remove fetch_latest_pkg_config().
etc/inc/pfsense-utils.inc | ||
---|---|---|
679 | 679 |
$fout = fopen("{$g['tmp_path']}/tmpxml","w"); |
680 | 680 |
fwrite($fout, $new_contents); |
681 | 681 |
fclose($fout); |
682 |
$section_xml = parse_xml_config($g['tmp_path'] . "/tmpxml", $section); |
|
682 |
$section_xml = parse_xml_config_pkg($g['tmp_path'] . "/tmpxml", $section);
|
|
683 | 683 |
$config[$section] = &$section_xml; |
684 | 684 |
unlink($g['tmp_path'] . "/tmpxml"); |
685 | 685 |
write_config("Restored {$section} of config file (maybe from CARP partner)"); |
... | ... | |
812 | 812 |
global $g; |
813 | 813 |
|
814 | 814 |
if($g['platform'] == "cdrom") |
815 |
return false;;
|
|
815 |
return; |
|
816 | 816 |
|
817 | 817 |
if (!is_file($path) && !is_dir($path)) |
818 |
return make_dirs($path, $mode);
|
|
818 |
return mkdir($path, $mode);
|
|
819 | 819 |
else |
820 | 820 |
return false; |
821 | 821 |
} |
... | ... | |
829 | 829 |
return is_dir($path) || (make_dirs(dirname($path), $mode) && safe_mkdir($path, $mode)); |
830 | 830 |
} |
831 | 831 |
|
832 |
/****f* pfsense-utils/auto_upgrade |
|
833 |
* NAME |
|
834 |
* auto_upgrade - pfSense autoupdate handler. |
|
835 |
* FUNCTION |
|
836 |
* Begin the pfSense autoupdate process. This function calls check_firmware_version to get |
|
837 |
* a list of current versions and then loops through them, applying binary diffs etc. |
|
838 |
* RESULT |
|
839 |
* null |
|
840 |
* BUGS |
|
841 |
* This function needs to have logic in place to automatically switch over to full updates |
|
842 |
* if a certain amount of binary diffs do not apply successfully. |
|
843 |
* SEE ALSO |
|
844 |
* pfsense.utils/check_firmware_version |
|
845 |
******/ |
|
846 |
function auto_upgrade() { |
|
847 |
global $config, $g; |
|
848 |
if (isset($config['system']['alt_firmware_url']['enabled'])) { |
|
849 |
$firmwareurl=$config['system']['alt_firmware_url']['firmware_base_url']; |
|
850 |
$firmwarepath=$config['system']['alt_firmware_url']['firmware_filename']; |
|
851 |
} else { |
|
852 |
$firmwareurl=$g['firmwarebaseurl']; |
|
853 |
$firmwarepath=$g['firmwarefilename']; |
|
854 |
} |
|
855 |
if($config['system']['proxy_auth_username'] <> "") |
|
856 |
$http_auth_username = $config['system']['proxy_auth_username']; |
|
857 |
if($config['system']['proxy_auth_password'] <> "") |
|
858 |
$http_auth_password = $config['system']['proxy_auth_password']; |
|
859 |
if (isset($config['system']['alt_firmware_url']['enabled'])) { |
|
860 |
$firmwareurl=$config['system']['alt_firmware_url']['firmware_base_url']; |
|
861 |
$firmwarename=$config['system']['alt_firmware_url']['firmware_filename']; |
|
862 |
} else { |
|
863 |
$firmwareurl=$g['firmwarebaseurl']; |
|
864 |
$firmwarename=$g['firmwarefilename']; |
|
865 |
} |
|
866 |
exec_rc_script_async("/etc/rc.firmware_auto {$firmwareurl} {$firmwarename} {$http_auth_username} {$http_auth_password}"); |
|
867 |
return; |
|
868 |
} |
|
869 |
|
|
832 | 870 |
/* |
833 | 871 |
* check_firmware_version(): Check whether the current firmware installed is the most recently released. |
834 | 872 |
*/ |
835 | 873 |
function check_firmware_version($tocheck = "all", $return_php = true) { |
836 | 874 |
global $g; |
837 |
$xmlrpc_base_url = $g['xmlrpcbaseurl']; |
|
838 |
$xmlrpc_path = $g['xmlrpcpath']; |
|
875 |
$versioncheck_base_url = $g['versioncheckbaseurl']; |
|
876 |
$versioncheck_path = $g['versioncheckpath']; |
|
877 |
if(isset($config['system']['alt_firmware_url']['enabled']) and isset($config['system']['alt_firmware_url']['versioncheck_base_url'])) { |
|
878 |
$versioncheck_base_url = $config['system']['alt_firmware_url']['versioncheck_base_url']; |
|
879 |
} |
|
839 | 880 |
$rawparams = array("firmware" => array("version" => trim(file_get_contents('/etc/version'))), |
840 | 881 |
"kernel" => array("version" => trim(file_get_contents('/etc/version_kernel'))), |
841 | 882 |
"base" => array("version" => trim(file_get_contents('/etc/version_base'))), |
... | ... | |
854 | 895 |
} |
855 | 896 |
$xmlparams = php_value_to_xmlrpc($params); |
856 | 897 |
$msg = new XML_RPC_Message('pfsense.get_firmware_version', array($xmlparams)); |
857 |
$cli = new XML_RPC_Client($xmlrpc_path, $xmlrpc_base_url);
|
|
898 |
$cli = new XML_RPC_Client($versioncheck_path, $versioncheck_base_url);
|
|
858 | 899 |
$resp = $cli->send($msg, 10); |
859 | 900 |
if(!$resp or $resp->faultCode()) { |
860 | 901 |
$raw_versions = false; |
... | ... | |
865 | 906 |
return $raw_versions; |
866 | 907 |
} |
867 | 908 |
|
868 |
/* |
|
869 |
* fetch_latest_pkg_config: download the latest pkg_config.xml to /tmp/ directory |
|
870 |
*/ |
|
871 |
function fetch_latest_pkg_config() { |
|
872 |
global $g; |
|
873 |
global $config; |
|
874 |
if(!file_exists("{$g['tmp_path']}/pkg_config.xml")) { |
|
875 |
$pkg_config_location = $g['pkg_config_location']; |
|
876 |
$pkg_config_base_url = $g['pkg_config_base_url']; |
|
877 |
if(isset($config['system']['alt_pkgconfig_url']['enabled'])) { |
|
878 |
$pkg_config_location = $config['system']['alt_pkgconfig_url']['pkgconfig_base_url'] . $config['system']['alt_pkgconfig_url']['pkgconfig_filename']; |
|
879 |
$pkg_config_base_url = $config['system']['alt_pkgconfig_url']['pkgconfig_base_url']; |
|
880 |
} |
|
881 |
mwexec("/usr/bin/fetch -o {$g['tmp_path']}/pkg_config.xml {$pkg_config_location}"); |
|
882 |
if(!file_exists("{$g['tmp_path']}/pkg_config.xml")) { |
|
883 |
print_info_box_np("Could not download pkg_config.xml from " . $pkg_config_base_url . ". Check your DNS settings."); |
|
884 |
die; |
|
885 |
} |
|
886 |
} |
|
887 |
return; |
|
909 |
function get_disk_info() { |
|
910 |
exec("df -h | grep -w '/' | awk '{ print $2, $3, $4, $5 }'", $diskout); |
|
911 |
return explode(' ', $diskout[0]); |
|
912 |
// $size, $used, $avail, $cap |
|
888 | 913 |
} |
889 | 914 |
|
890 | 915 |
?> |
Also available in: Unified diff