Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 3 > Installation/Configuration

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 13th May 2009, 08:17
admins admins is offline
Senior Member
 
Join Date: Apr 2009
Location: Switzerland
Posts: 210
Thanks: 6
Thanked 3 Times in 3 Posts
Default automatic webmail link

Hi till
Hi all

I want when I create a new site, that ISPConfig automatic set a Symlink to
/var/www/webmail in the webpart of the new customer.

So that I do not must everytime set the symlink.

thanks for ideas.
admins
Reply With Quote
Sponsored Links
  #2  
Old 13th May 2009, 09:11
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,457
Thanks: 813
Thanked 5,239 Times in 4,107 Posts
Default

E.g. you can write a plugin for that.
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #3  
Old 13th May 2009, 09:16
admins admins is offline
Senior Member
 
Join Date: Apr 2009
Location: Switzerland
Posts: 210
Thanks: 6
Thanked 3 Times in 3 Posts
Default

How could I do this?
Could you do this for me? Is this a big work?

Thanks
admins
Reply With Quote
  #4  
Old 30th May 2009, 18:25
3cwired_com 3cwired_com is offline
Senior Member
 
Join Date: Sep 2006
Posts: 100
Thanks: 3
Thanked 3 Times in 2 Posts
Default

I would like this feature also. thanks.
__________________
Behind every great fortune lies a crime.
www.3cwired.com - Web Design/SEO/Repair/Sales/Upgrades
www.galants.org - The Home for Galant Enthusiasts
www.locatemyip.com - More than just free IP displays
Reply With Quote
  #5  
Old 3rd June 2009, 21:35
SamTzu SamTzu is offline
HowtoForge Supporter
 
Join Date: Apr 2007
Location: Helsinki
Posts: 426
Thanks: 33
Thanked 55 Times in 38 Posts
Send a message via Skype™ to SamTzu
Default

Friends, please.
If You want Falco or Till to work for You, You should at least pay them for their work.
Just my humble opinion. I find it difficult to get people to work free for me (or if they do, the deadlines are just horrible.)
__________________

Sami Mattila
Internet-Content

Telephone:
00358942833310
Email: firstname.lastname@internet-content.org
Shop: http://shop.internet-content.net
Site: http://www.internet-content.net
Blog: http://www.internet-content.net/en/blog
FB: https://www.facebook.com/internetcontent

Reply With Quote
The Following User Says Thank You to SamTzu For This Useful Post:
AbannyvabVask (29th November 2013)
  #6  
Old 4th June 2009, 09:13
Croydon Croydon is offline
ISPConfig Developer
 
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 922
Thanks: 16
Thanked 258 Times in 206 Posts
Default

I got a plugin ready for this.

Just copy the content to a file
Code:
/usr/local/ispconfig/server/plugins-available/webmail_symlink_plugin.inc.php
and create a symlink in plugins-enabled
Code:
ln -s /usr/local/ispconfig/server/plugins-available/webmail_symlink_plugin.inc.php /usr/local/ispconfig/server/plugins-enabled/webmail_symlink_plugin.inc.php
Please note: the symlink is automatically removed / not created if suphp is enabled for this website as suphp doesn't allow symlinks outside the docroot.

PHP Code:
<?php

/*
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Modification (c) 2009, Marius Cramer, pixcept KG

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

class webmail_symlink_plugin {
    
    var 
$plugin_name 'webmail_symlink_plugin';
    var 
$class_name 'webmail_symlink_plugin';
    
    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
    */
    
    
function onLoad() {
        global 
$app;
        
        
/*
        Register for the events
        */
        
        
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert');
        
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
    }
    
    function 
insert($event_name,$data) {
        global 
$app$conf;
        
        
$this->action 'insert';
        
// just run the update function
        
$this->update($event_name,$data);
    }
    
    function 
update($event_name,$data) {
        global 
$app$conf;
        
        if(
$this->action != 'insert'$this->action 'update';
        
        if(
$data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
            
            
$old_parent_domain_id intval($data["old"]["parent_domain_id"]);
            
$new_parent_domain_id intval($data["new"]["parent_domain_id"]);
            
            
// If the parent_domain_id has been chenged, we will have to update the old site as well.
            
if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
                
$tmp $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
                
$data["new"] = $tmp;
                
$data["old"] = $tmp;
                
$this->action 'update';
                
$this->update($event_name,$data);
            }
            
            
// This is not a vhost, so we need to update the parent record instead.
            
$tmp $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
            
$data["new"] = $tmp;
            
$data["old"] = $tmp;
            
$this->action 'update';
        }
        
        if(
$data["new"]["document_root"] == '') {
            
$app->log("document_root not set",LOGLEVEL_WARN);
            return 
0;
        }
        
        if(!
is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
        if(
$data["new"]["php"] == "suphp") {
            if(
is_link($data["new"]["document_root"]."/web/webmail")) exec("rm -f ".$data["new"]["document_root"]."/web/webmail");
        } else {
            if(!
is_link($data["new"]["document_root"]."/web/webmail")) exec("ln -s /var/www/webmail ".$data["new"]["document_root"]."/web/webmail");
            else 
exec("ln -sf /var/www/webmail ".$data["new"]["document_root"]."/web/webmail");
        }
    }
    

// end class

?>
Reply With Quote
The Following 4 Users Say Thank You to Croydon For This Useful Post:
falko (4th June 2009), KillerSneak (22nd June 2009), the1matrix1 (24th June 2009), till (4th June 2009)
  #7  
Old 4th June 2009, 09:43
till till is offline
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 35,457
Thanks: 813
Thanked 5,239 Times in 4,107 Posts
Default

Thank you very much for the plugin!

Also the combination php as cgi + suexec or php-fcgi + suexec might have the same problem as suphp if the scripts for the webmail application are not within /var/www or do not belong to the admin user of the site, so it might be a good idea to exclude these combinations also from symlinking?
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
  #8  
Old 4th June 2009, 09:47
Croydon Croydon is offline
ISPConfig Developer
 
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 922
Thanks: 16
Thanked 258 Times in 206 Posts
Default

Quote:
Originally Posted by till View Post
Thank you very much for the plugin!

Also the combination php as cgi + suexec or php-fcgi + suexec might have the same problem as suphp if the scripts for the webmail application are not within /var/www or do not belong to the admin user of the site, so it might be a good idea to exclude these combinations also from symlinking?
I tested the plugin with a site with cgi, fast-cgi, modphp enabled and had no problems yet. But maybe you are right that there are some functions that would not work correctly. I am really not sure about that.


edit: sorry, you are right! i didn't set the suexec option so you are right. with that enabled there might be problems. I'll change the plugin.

Last edited by Croydon; 4th June 2009 at 10:05. Reason: missed something
Reply With Quote
  #9  
Old 4th June 2009, 10:10
Croydon Croydon is offline
ISPConfig Developer
 
Join Date: Jul 2007
Location: Koblenz, Germany
Posts: 922
Thanks: 16
Thanked 258 Times in 206 Posts
Default

Here is the updated plugin.

Symlink is now disabled when
  • suPHP is used
  • CGI is used with suexec
  • Fast-CGI is used with suexec

PHP Code:
<?php

/*
Copyright (c) 2007 - 2009, Till Brehm, projektfarm Gmbh
All rights reserved.
Modification (c) 2009, Marius Cramer, pixcept KG 

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

    * Redistributions of source code must retain the above copyright notice,
      this list of conditions and the following disclaimer.
    * Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
    * Neither the name of ISPConfig nor the names of its contributors
      may be used to endorse or promote products derived from this software without
      specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

class webmail_symlink_plugin {
    
    var 
$plugin_name 'webmail_symlink_plugin';
    var 
$class_name 'webmail_symlink_plugin';
    
    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
    */
    
    
function onLoad() {
        global 
$app;
        
        
/*
        Register for the events
        */
        
        
$app->plugins->registerEvent('web_domain_insert',$this->plugin_name,'insert');
        
$app->plugins->registerEvent('web_domain_update',$this->plugin_name,'update');
    }
    
    function 
insert($event_name,$data) {
        global 
$app$conf;
        
        
$this->action 'insert';
        
// just run the update function
        
$this->update($event_name,$data);
    }
    
    function 
update($event_name,$data) {
        global 
$app$conf;
        
        if(
$this->action != 'insert'$this->action 'update';
        
        if(
$data["new"]["type"] != "vhost" && $data["new"]["parent_domain_id"] > 0) {
            
            
$old_parent_domain_id intval($data["old"]["parent_domain_id"]);
            
$new_parent_domain_id intval($data["new"]["parent_domain_id"]);
            
            
// If the parent_domain_id has been chenged, we will have to update the old site as well.
            
if($this->action == 'update' && $data["new"]["parent_domain_id"] != $data["old"]["parent_domain_id"]) {
                
$tmp $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$old_parent_domain_id." AND active = 'y'");
                
$data["new"] = $tmp;
                
$data["old"] = $tmp;
                
$this->action 'update';
                
$this->update($event_name,$data);
            }
            
            
// This is not a vhost, so we need to update the parent record instead.
            
$tmp $app->db->queryOneRecord("SELECT * FROM web_domain WHERE domain_id = ".$new_parent_domain_id." AND active = 'y'");
            
$data["new"] = $tmp;
            
$data["old"] = $tmp;
            
$this->action 'update';
        }
        
        if(
$data["new"]["document_root"] == '') {
            
$app->log("document_root not set",LOGLEVEL_WARN);
            return 
0;
        }
        
        
$symlink true;
        if(
$data["new"]["php"] == "suphp"$symlink false;
        elseif(
$data["new"]["php"] == "cgi" && $data["new"]["suexec"] == "y"$symlink false;
        elseif(
$data["new"]["php"] == "fast-cgi" && $data["new"]["suexec"] == "y"$symlink false;
        
        
        if(!
is_dir($data["new"]["document_root"]."/web")) exec("mkdir -p ".$data["new"]["document_root"]."/web");
        if(
$symlink == false) {
            if(
is_link($data["new"]["document_root"]."/web/webmail")) exec("rm -f ".$data["new"]["document_root"]."/web/webmail");
        } else {
            if(!
is_link($data["new"]["document_root"]."/web/webmail")) exec("ln -s /var/www/webmail ".$data["new"]["document_root"]."/web/webmail");
            else 
exec("ln -sf /var/www/webmail ".$data["new"]["document_root"]."/web/webmail");
        }
    }
    

// end class

?>
Reply With Quote
The Following 5 Users Say Thank You to Croydon For This Useful Post:
admins (10th June 2009), falko (4th June 2009), KillerSneak (22nd June 2009), the1matrix1 (18th June 2009), till (4th June 2009)
  #10  
Old 14th June 2009, 20:41
pmcdougl pmcdougl is offline
Junior Member
 
Join Date: Nov 2008
Location: Minnesota
Posts: 9
Thanks: 2
Thanked 0 Times in 0 Posts
 
Default

Hi, I just tried this and when I try to access any of the websites I create and go to the webmail directory, I get a 403 forbidden...did I do something wrong?

for example, I have site1.something.com, and site2.something.com...when I go to site1.something.com/webmail I get a 403 forbidden (in site2 as well). The symlinks are in the web directories of both the sites, but I still get the 403. Also, when I login via FTP it says that webmail is a broken link, but I suspect this to be normal, as my ftp login cannot see into other directories on the system.

Any words of wisdom?
Thanks in advance
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Ubuntu Hardy chrooted bind9 fails to start Djamu Server Operation 35 21st April 2010 08:28
watchdog_task: NIC Link is Up 10 Mbps Full Duplex Chad Server Operation 0 8th October 2008 03:04
VMWare Server on Debian Etch Link is down/up BriX HOWTO-Related Questions 3 8th January 2008 22:31
colocation problem d3m0nic Installation/Configuration 14 23rd June 2006 23:18
simpler link to webmail t_ras General 1 10th February 2006 00:24


All times are GMT +2. The time now is 04:02.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.