direct symlink to website in /home/sites/[website_domain]/

Discussion in 'General' started by Marcin-i, Feb 20, 2018.

  1. Marcin-i

    Marcin-i New Member

    Hi,
    because of migration of existing user directories to ispconfig 3, I have to create direct links to web folder from folder:
    Code:
    /home/sites/[website_domain]/
    when i use Website symlinks, this passess whole tree to /home/sites/[website_domain]/. What I am trying to achieve is symlink from:
    Code:
    /home/sites/[website_domain]/ -> /var/www/clients/client[client_id]/web[website_id]/web
    is it possible without manualy creating this scheme one by one?

    thanks for help,
    Marcin
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Th automatically created symlink always point to the web root, not the 'web' folder in the web root, so you will probably have to create these symlinks manually.
     
  3. Marcin-i

    Marcin-i New Member

    Thanks for answer Till,
    Is there any option to run custom script when creating new website automaticly?
     
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Yes, you can have custom ISPConfig plugins that subscribe to events like the website insert event.

    Here a small example:

    PHP:
    <?php

    class xcustom_plugin {

        var 
    $plugin_name 'xcustom';
        var 
    $class_name 'xcustom';

        
    //* 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');
            
    $app->plugins->registerEvent('web_domain_delete'$this->plugin_name'delete');
        }
       
        function 
    insert($event_name$data) {
            global 
    $app$conf;
           
            
    // Add some code here
           
        
    }
       
        function 
    update($event_name$data) {
            global 
    $app$conf;
           
            
    // Add some code here
           
        
    }
       
        function 
    delete($event_name$data) {
            global 
    $app$conf;
           
            
    // Add some code here
           
        
    }
    }
    save this file as /usr/local/ispconfig/server/plugins-available/xcustom_plugin.inc.php

    Then create a symlink in plugins-enabled folder that points to this plugin file and finally add your code in the insert, update and delete functions. The $data variable is an array which contains the whole new and old dataset of the website. e.g. the domain name is $data['new']['domain'] and in case the domain of a site changes, then you can find the old domain name in $data['old']['domain'] while the new one is $data['new']['domain'] so you can rename your symlink in such a case.
     
  5. Marcin-i

    Marcin-i New Member

    great anwer, thanks for support I will share my solution if I will get this working
    Best regards,
    Marcin
     

Share This Page