summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorColin Smith <colin@pfsense.org>2005-03-13 22:44:05 +0000
committerColin Smith <colin@pfsense.org>2005-03-13 22:44:05 +0000
commit5c52313ff22e654c4bb38ae570eba16e621edeca (patch)
tree951698d12a409af76bc8e6e7f7fc5f99f2198963 /etc
parent7197df7d99366dfcf33637aaa1fe964cd3fdeb73 (diff)
downloadpfsense-5c52313ff22e654c4bb38ae570eba16e621edeca.zip
pfsense-5c52313ff22e654c4bb38ae570eba16e621edeca.tar.gz
Add sync_package().
Diffstat (limited to 'etc')
-rw-r--r--etc/inc/pfsense-utils.inc47
1 files changed, 43 insertions, 4 deletions
diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc
index 97bd036..533715d 100644
--- a/etc/inc/pfsense-utils.inc
+++ b/etc/inc/pfsense-utils.inc
@@ -43,7 +43,7 @@ function log_error($error) {
function return_dir_as_array($dir) {
$dir_array = array();
if (is_dir($dir)) {
- if ($dh = opendir($dir)) {
+ If ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
$canadd = 0;
if($file == ".") $canadd = 1;
@@ -571,7 +571,7 @@ function resync_all_package_configs_bootup($show_message) {
if($show_message == true) print "\n\nFetching " . $package['configurationfile'] . ".\n";
log_error("Fetching missing configuration XML for " . $package['name']);
system("/usr/bin/fetch -o /usr/local/pkg/" . $package['configurationfile'] . " http://www.pfsense.com/packages/config/" . $package['configurationfile']);
- print "\n\n";
+ if($show_message == true) print "\n\n";
}
$pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
if(isset($pkg_config['nosync'])) continue;
@@ -605,7 +605,7 @@ function resync_all_package_configs_bootup($show_message) {
if($show_message == true) print " " . $item_config['name'];
}
}
- print ".\n";
+ if($show_message == true) print ".\n";
}
/*
@@ -868,5 +868,44 @@ if (!function_exists('php_check_syntax')){
}
}
-
+/*
+ * sync_package($pkg_name, $show_message) Force a package to setup its configuration and rc.d files.
+ */
+function sync_package($pkg_name, $sync_depends = true, $show_message = true) {
+ global $config;
+ if(!$config['installedpackages']['package']) return;
+ foreach($config['installedpackages']['package'] as $package) {
+ if($package['name'] != $pkg_name) continue;
+ if(!file_exists("/usr/local/pkg/" . $package['configurationfile'])) {
+ if($show_message == true) print "\n\nFetching " . $package['configurationfile'] . ".\n";
+ log_error("Fetching missing configuration XML for " . $package['name']);
+ system("/usr/bin/fetch -o /usr/local/pkg/" . $package['configurationfile'] . " http://www.pfsense.com/packages/config/" . $package['configurationfile']);
+ if($show_message == true) print "\n\n";
+ }
+ $pkg_config = parse_xml_config_pkg("/usr/local/pkg/" . $package['configurationfile'], "packagegui");
+ if(isset($pkg_config['nosync'])) continue;
+ if($show_message == true) print "Syncing " . $pkg_name;
+ if($pkg_config['custom_php_command_before_form'] <> "") {
+ eval($pkg_config['custom_php_command_before_form']);
+ }
+ if($pkg_config['custom_php_resync_config_command'] <> "") {
+ eval($pkg_config['custom_php_resync_config_command']);
+ }
+ if ($sync_depends == true) {
+ $depends = get_pkg_depends($package['name'], ".xml", "files", 0); // Call dependency handler and do a little more error checking.
+ if(is_array($depends)) {
+ foreach($depends as $item) {
+ $item_config = parse_xml_config_pkg("/usr/local/pkg/" . $item, "packagegui");
+ if (isset($item_config['nosync'])) continue;
+ if($item_config['custom_php_command_before_form'] <> "")
+ eval($item_config['custom_php_command_before_form']);
+ if($item_config['custom_php_resync_config_command'] <> "")
+ eval($item_config['custom_php_resync_config_command']);
+ if($show_message == true) print " " . $item_config['name'];
+ }
+ }
+ }
+ }
+ print ".";
+}
?>
OpenPOWER on IntegriCloud