From 87362af36b6e0a51bf91285173af133fa40070f6 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Tue, 15 Mar 2005 23:43:17 +0000 Subject: * Introduce is_package_instaleld() * Use is_package_installed to figure out if we should install a squid rule --- etc/inc/filter.inc | 6 ++---- etc/inc/pfsense-utils.inc | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 6 deletions(-) (limited to 'etc') diff --git a/etc/inc/filter.inc b/etc/inc/filter.inc index 451389f..62eb50f 100644 --- a/etc/inc/filter.inc +++ b/etc/inc/filter.inc @@ -880,10 +880,8 @@ EOD; } } - $squid_installed = run_command_return_string("/bin/ls {$g['vardb_path']}/pkg/ | grep squid"); - if ($squid_installed <> "") { + if (is_package_installed("squid") == 1) $natrules .= "rdr on " . $lanif . " inet proto tcp from any to !{$lanip} port www -> 127.0.0.1 port 3128\n"; - } return $natrules; } @@ -1356,7 +1354,7 @@ EOD; if($rule['returngateway'] <> "") { $line .= "reply-to (" . $rule['returngateway'] . ") "; } - + if (isset($rule['protocol'])) { if($rule['protocol'] == "tcp/udp") $line .= "proto { tcp udp } "; diff --git a/etc/inc/pfsense-utils.inc b/etc/inc/pfsense-utils.inc index 6282c51..ac3bf54 100644 --- a/etc/inc/pfsense-utils.inc +++ b/etc/inc/pfsense-utils.inc @@ -339,6 +339,17 @@ function remove_text_from_file($file, $text) { } /* + * is_package_installed($packgename): returns 1 if a package is installed, 0 otherwise. + */ +function is_package_installed($packagename) { + global $config; + foreach($config['installedpackages']['package'] as $package) { + if($package['name'] == "squid") return 1; + } + return 0; +} + +/* * lookup pkg array id# */ function get_pkg_id($pkg_name) { @@ -875,12 +886,14 @@ function sync_package($pkg_name, $sync_depends = true, $show_message = false) { 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'] <> "") + if($item_config['custom_php_command_before_form'] <> "") { eval($item_config['custom_php_command_before_form']); print "Evaled dependency."; - if($item_config['custom_php_resync_config_command'] <> "") + } + if($item_config['custom_php_resync_config_command'] <> "") { eval($item_config['custom_php_resync_config_command']); print "Evaled dependency."; + } if($show_message == true) print " " . $item_config['name']; } } -- cgit v1.1