aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Ullrich <sullrich@pfsense.org>2010-04-27 21:21:51 -0400
committerScott Ullrich <sullrich@pfsense.org>2010-04-27 21:21:51 -0400
commitf78a59ea47984775f69368f59d88012e521f3653 (patch)
tree8aa320971186c12fc1cb1f24259c01119c1a4042
parentbc96caa0744c855deac346dc282513dfbff5e017 (diff)
downloadpfsense-packages-f78a59ea47984775f69368f59d88012e521f3653.tar.gz
pfsense-packages-f78a59ea47984775f69368f59d88012e521f3653.tar.bz2
pfsense-packages-f78a59ea47984775f69368f59d88012e521f3653.zip
Eliminate a case where a LB Director and a Backend may have the same name by appending BACKEND to the end of all backend names
-rw-r--r--config/varnish64/varnish.inc39
-rw-r--r--config/varnish64/varnish_backends.xml5
-rw-r--r--config/varnish64/varnish_custom_vcl.xml1
-rw-r--r--config/varnish64/varnish_lb_directors.xml2
-rw-r--r--config/varnish64/varnish_settings.xml1
5 files changed, 39 insertions, 9 deletions
diff --git a/config/varnish64/varnish.inc b/config/varnish64/varnish.inc
index e098e20a..7535b1bb 100644
--- a/config/varnish64/varnish.inc
+++ b/config/varnish64/varnish.inc
@@ -31,6 +31,18 @@
*/
/* ========================================================================== */
+function varnish_install() {
+ create_varnish_rcd_file();
+}
+
+function varnish_deinstall() {
+ create_varnish_rcd_file();
+}
+
+function varnish_start() {
+ mwexec("/usr/local/etc/rc.d/varnish.sh");
+}
+
/* Return true if a backend is in use */
function is_varnish_backend_in_use($backendname) {
global $g, $config;
@@ -75,7 +87,7 @@ EOAU;
$urlmappings .= "else ";
$urlmappings .= <<<EOAU
if (req.http.host == "{$url['urlmapping']}") {
- set req.backend = {$urlmapping['backendname']};
+ set req.backend = {$urlmapping['backendname']}BACKEND;
set req.http.host = "{$urlmapping['urlmapping']}";
}
EOAU;
@@ -119,6 +131,16 @@ mkdir -p /var/varnish
rm /var/varnish/storage.bin 2>/dev/null
killall varnishd 2>/dev/null
sleep 1
+/usr/bin/env \
+PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \
+/usr/local/bin/php -q -d auto_prepend_file=config.inc <<ENDOFF
+<?php
+ require_once("globals.inc");
+ require_once("functions.inc");
+ require_once("varnish.inc");
+ sync_package_varnish();
+?>
+ENDOFF
/usr/local/sbin/varnishd \
{$listeningport} \
-f /var/etc/default.vcl \
@@ -133,6 +155,7 @@ EOF;
function get_backend_config_txt() {
global $config, $g;
+ $backends_used = array();
if($config['installedpackages']['varnishbackends']['config'] != "") {
foreach($config['installedpackages']['varnishbackends']['config'] as $backend) {
if($backend['connect_timeout'])
@@ -168,8 +191,9 @@ function get_backend_config_txt() {
else
$probe_threshold = "5";
if(is_varnish_backend_in_use($backend['backendname']))
- $backends .= <<<EOFA
-backend {$backend['backendname']} {
+ if(!in_array($backend['backendname'], $backends_used))
+ $backends .= <<<EOFA
+backend {$backend['backendname']}BACKEND {
.host = "{$backend['ipaddress']}";
.port = "{$backend['port']}";
.first_byte_timeout = {$first_byte_timeout};
@@ -183,7 +207,9 @@ backend {$backend['backendname']} {
}
}
+
EOFA;
+ $backends_used[] = $backend['backendname'];
}
}
return $backends;
@@ -200,7 +226,7 @@ function get_lb_directors_config_txt() {
$weight = "\t\t\t.weight = {$be['weight']};\n";
else
$weight = "";
- $director .= "\t{\n\t\t.backend = {$be['backendname']};\n{$weight}\t}";
+ $director .= "\t{\n\t\t.backend = {$be['backendname']}BACKEND;\n{$weight}\t}";
}
$backends .= <<<EOFA
director {$backend['directorname']} {$backend['directortype']} {
@@ -233,8 +259,6 @@ function sync_package_varnish() {
}
}
- create_varnish_rcd_file();
-
if(!$errorvcl)
$errorvcl = <<<EOF
set obj.http.Content-Type = "text/html; charset=utf-8";
@@ -341,7 +365,6 @@ EOF;
$fd = fopen("/var/etc/default.vcl", "w");
fwrite($fd, $varnish_config_file);
fclose($fd);
- exec("/usr/local/etc/rc.d/varnish.sh");
varnish_sync_on_changes();
}
@@ -371,8 +394,6 @@ function varnish_sync_on_changes() {
if($password && $sync_to_ip)
varnish_do_xmlrpc_sync($sync_to_ip, $password);
}
- varnish_create_zone_file();
- varnish_setup_ping_items();
log_error("[varnish] varnish_xmlrpc_sync.php is ending.");
}
diff --git a/config/varnish64/varnish_backends.xml b/config/varnish64/varnish_backends.xml
index 1ee2a142..65a03499 100644
--- a/config/varnish64/varnish_backends.xml
+++ b/config/varnish64/varnish_backends.xml
@@ -183,12 +183,17 @@
</rowhelper>
</field>
</fields>
+ <custom_php_install_command>
+ varnish_install();
+ </custom_php_install_command>
<custom_php_command_before_form>
</custom_php_command_before_form>
<custom_delete_php_command>
sync_package_varnish();
+ varnish_start();
</custom_delete_php_command>
<custom_php_resync_config_command>
sync_package_varnish();
+ varnish_start();
</custom_php_resync_config_command>
</packagegui> \ No newline at end of file
diff --git a/config/varnish64/varnish_custom_vcl.xml b/config/varnish64/varnish_custom_vcl.xml
index 7b35426a..0794d825 100644
--- a/config/varnish64/varnish_custom_vcl.xml
+++ b/config/varnish64/varnish_custom_vcl.xml
@@ -126,5 +126,6 @@
</custom_php_validation_command>
<custom_php_resync_config_command>
sync_package_varnish();
+ varnish_start();
</custom_php_resync_config_command>
</packagegui> \ No newline at end of file
diff --git a/config/varnish64/varnish_lb_directors.xml b/config/varnish64/varnish_lb_directors.xml
index a622ad46..4d41687c 100644
--- a/config/varnish64/varnish_lb_directors.xml
+++ b/config/varnish64/varnish_lb_directors.xml
@@ -151,8 +151,10 @@
</custom_php_command_before_form>
<custom_delete_php_command>
sync_package_varnish();
+ varnish_start();
</custom_delete_php_command>
<custom_php_resync_config_command>
sync_package_varnish();
+ varnish_start();
</custom_php_resync_config_command>
</packagegui> \ No newline at end of file
diff --git a/config/varnish64/varnish_settings.xml b/config/varnish64/varnish_settings.xml
index 988fe0db..82f1fa18 100644
--- a/config/varnish64/varnish_settings.xml
+++ b/config/varnish64/varnish_settings.xml
@@ -118,5 +118,6 @@
</custom_php_validation_command>
<custom_php_resync_config_command>
sync_package_varnish();
+ varnish_start();
</custom_php_resync_config_command>
</packagegui> \ No newline at end of file