From 7227e86264ce29150c51a289fea143af53108d4e Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Thu, 18 Dec 2008 07:34:05 -0500
Subject: [PATCH] Replace website symlink in /var/www when target directory has been changed.
---
server/plugins-available/apache2_plugin.inc.php | 42 ++++++++++++++++++++++++++++++++++++------
1 files changed, 36 insertions(+), 6 deletions(-)
diff --git a/server/plugins-available/apache2_plugin.inc.php b/server/plugins-available/apache2_plugin.inc.php
index 7ebeedb..da6d877 100644
--- a/server/plugins-available/apache2_plugin.inc.php
+++ b/server/plugins-available/apache2_plugin.inc.php
@@ -36,6 +36,19 @@
// private variables
var $action = '';
+ //* This function is called during ispconfig installation to determine
+ // if a symlink shall be created for this plugin.
+ function onInstall() {
+ global $conf;
+
+ if($conf['services']['web'] == true) {
+ return true;
+ } else {
+ return false;
+ }
+
+ }
+
/*
This function is called when the plugin is loaded
@@ -289,6 +302,10 @@
$tmp_symlink = str_replace("[website_domain]",$data["new"]["domain"],$tmp_symlink);
// Remove trailing slash
if(substr($tmp_symlink, -1, 1) == '/') $tmp_symlink = substr($tmp_symlink, 0, -1);
+ //* Remove symlink if target folder has been changed.
+ if($data["old"]["document_root"] != '' && $data["old"]["document_root"] != $data["new"]["document_root"] && is_link($tmp_symlink)) {
+ unlink($tmp_symlink);
+ }
// create the symlinks, if not exist
if(!is_link($tmp_symlink)) {
exec("ln -s ".escapeshellcmd($data["new"]["document_root"])."/ ".escapeshellcmd($tmp_symlink));
@@ -407,14 +424,27 @@
// get alias domains (co-domains and subdomains)
$aliases = $app->db->queryAllRecords("SELECT * FROM web_domain WHERE parent_domain_id = ".$data["new"]["domain_id"]." AND active = 'y'");
- if($data["new"]["is_subdomainwww"]){
- $server_alias .= 'www.'.$data["new"]["domain"].' ';
- } else {
- $server_alias = '';
- }
+ switch($data["new"]["subdomain"]) {
+ case 'www':
+ $server_alias .= 'www.'.$data["new"]["domain"].' ';
+ break;
+ case '*':
+ $server_alias .= '*.'.$data["new"]["domain"].' ';
+ break;
+ }
if(is_array($aliases)) {
foreach($aliases as $alias) {
- $server_alias .= $alias["domain"].' ';
+ switch($alias["subdomain"]) {
+ case 'www':
+ $server_alias .= 'www.'.$alias["domain"].' '.$alias["domain"].' ';
+ break;
+ case '*':
+ $server_alias .= '*.'.$alias["domain"].' '.$alias["domain"].' ';
+ break;
+ default:
+ $server_alias .= $alias["domain"].' ';
+ break;
+ }
$app->log("Add server alias: $alias[domain]",LOGLEVEL_DEBUG);
// Rewriting
if($alias["redirect_type"] != '') {
--
Gitblit v1.9.1