tbrehm
2008-12-26 7ff27228bdf12d4f5f6c303cf95d01aac9cb291e
install/lib/installer_base.lib.php
@@ -35,7 +35,7 @@
   var $db;
   public $conf;
   public $install_ispconfig_interface = true;
   public $is_update = false; // true if it is an update, falsi if it is a new install
    public function __construct()
@@ -159,6 +159,11 @@
         if(count($db_tables) == 0) {
            $this->error('Unable to load SQL-Dump into database table.');
         }
         //* Load system.ini into the sys_ini table
         $system_ini = $this->db->quote(rf('tpl/system.ini.master'));
         $this->db->query("UPDATE sys_ini SET config = '$system_ini' WHERE sysini_id = 1");
      }
   }
   
@@ -222,18 +227,24 @@
         
         //* insert the ispconfig user in the remote server
         $from_host = $conf['hostname'];
         $from_ip = gethostbyname($conf['hostname']);
         
         //* username for the ispconfig user
         $conf['mysql']['master_ispconfig_user'] = 'ispconfigserver'.$conf['server_id'];
      
         //* Delete ISPConfig user in the local database, in case that it exists
         //* Delete ISPConfig user in the master database, in case that it exists
         $this->dbmaster->query("DELETE FROM mysql.user WHERE User = '".$conf['mysql']['master_ispconfig_user']."' AND Host = '".$from_host."';");
         $this->dbmaster->query("DELETE FROM mysql.db WHERE Db = '".$conf['mysql']['master_database']."' AND Host = '".$from_host."';");
         $this->dbmaster->query("DELETE FROM mysql.user WHERE User = '".$conf['mysql']['master_ispconfig_user']."' AND Host = '".$from_ip."';");
         $this->dbmaster->query("DELETE FROM mysql.db WHERE Db = '".$conf['mysql']['master_database']."' AND Host = '".$from_ip."';");
         $this->dbmaster->query('FLUSH PRIVILEGES;');
      
         //* Create the ISPConfig database user in the local database
           $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$conf['mysql']['master_database'].".* "
                   ."TO '".$conf['mysql']['master_ispconfig_user']."'@'".$from_host."' "
                   ."IDENTIFIED BY '".$conf['mysql']['master_ispconfig_password']."';";
         $query = 'GRANT SELECT, INSERT, UPDATE, DELETE ON '.$conf['mysql']['master_database'].".* "
                   ."TO '".$conf['mysql']['master_ispconfig_user']."'@'".$from_ip."' "
                   ."IDENTIFIED BY '".$conf['mysql']['master_ispconfig_password']."';";
         if(!$this->dbmaster->query($query)) {
            $this->error('Unable to create database user in master database: '.$conf['mysql']['master_ispconfig_user'].' Error: '.$this->dbmaster->errorMessage);
@@ -688,6 +699,15 @@
         replaceLine('/etc/suphp/suphp.conf','docroot=','docroot=/var/clients',0);
      }
      
      //* Copy the ISPConfig configuration include
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
      copy('tpl/apache_ispconfig.conf.master',$vhost_conf_dir.'/ispconfig.conf');
      if(!@is_link($vhost_conf_enabled_dir."/000-ispconfig.conf")) {
         exec("ln -s ".$vhost_conf_dir."/ispconfig.conf ".$vhost_conf_enabled_dir."/000-ispconfig.conf");
      }
   }
   
   public function configure_firewall()
@@ -714,9 +734,15 @@
          $tcp_public_services = trim(str_replace(',',' ',$row["tcp_port"]));
          $udp_public_services = trim(str_replace(',',' ',$row["udp_port"]));
        } else {
          $tcp_public_services = '21 22 25 53 80 110 443 8080 10000';
          $tcp_public_services = '21 22 25 53 80 110 443 3306 8080 10000';
          $udp_public_services = '53';
        }
      if(!stristr($tcp_public_services, $conf['apache']['vhost_port'])) {
         $tcp_public_services .= ' '.intval($conf['apache']['vhost_port']);
         if($row["tcp_port"] != '') $this->db->query("UPDATE firewall SET tcp_port = tcp_port + ',".intval($conf['apache']['vhost_port'])."' WHERE server_id = ".intval($conf['server_id']));
      }
        $content = str_replace("{TCP_PUBLIC_SERVICES}", $tcp_public_services, $content);
        $content = str_replace("{UDP_PUBLIC_SERVICES}", $udp_public_services, $content);
@@ -849,7 +875,7 @@
                  include_once($install_dir.'/server/plugins-available/'.$file);
                  $plugin_name = substr($file,0,-8);
                  $tmp = new $plugin_name;
                  if($tmp->onInstall()) {
                  if(method_exists($tmp,'onInstall') && $tmp->onInstall()) {
                     if(!@is_link($install_dir.'/server/plugins-enabled/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-enabled/'.$file);
                     if (strpos($file, '_core_plugin') !== false) {
                        if(!@is_link($install_dir.'/server/plugins-core/'.$file)) @symlink($install_dir.'/server/plugins-available/'.$file, $install_dir.'/server/plugins-core/'.$file);
@@ -873,6 +899,7 @@
      
      if($conf['mysql']['master_slave_setup'] == 'y') {
         $this->dbmaster->query($sql);
         $this->db->query($sql);
      } else {
         $this->db->query($sql);
      }
@@ -927,13 +954,11 @@
      caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
      
      //* Copy the ISPConfig vhost for the controlpanel
        // TODO: These are missing! should they be "vhost_dist_*_dir" ?
        $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
        $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
        
        
        // Dont just copy over the virtualhost template but add some custom settings
        $content = rf("tpl/apache_ispconfig.vhost.master");
      $content = str_replace('{vhost_port}', $conf['apache']['vhost_port'], $content);
      
@@ -948,7 +973,7 @@
      
      //copy('tpl/apache_ispconfig.vhost.master', "$vhost_conf_dir/ispconfig.vhost");
      //* and create the symlink
      if($this->install_ispconfig_interface == true) {
      if($this->install_ispconfig_interface == true && $this->is_update == false) {
         if(@is_link("$vhost_conf_enabled_dir/ispconfig.vhost")) unlink("$vhost_conf_enabled_dir/ispconfig.vhost");
         if(!@is_link("$vhost_conf_enabled_dir/000-ispconfig.vhost")) {
            exec("ln -s $vhost_conf_dir/ispconfig.vhost $vhost_conf_enabled_dir/000-ispconfig.vhost");
@@ -1018,8 +1043,8 @@
      }
      
      $root_cron_jobs = array(
         '* * * * * /usr/local/ispconfig/server/server.sh > /dev/null',
         '30 00 * * * /usr/local/ispconfig/server/cron_daily.sh > /dev/null'
         '* * * * * /usr/local/ispconfig/server/server.sh > /dev/null 2>> /var/log/ispconfig/cron.log',
         '30 00 * * * /usr/local/ispconfig/server/cron_daily.sh > /dev/null 2>> /var/log/ispconfig/cron.log'
      );
      foreach($root_cron_jobs as $cron_job) {
         if(!in_array($cron_job."\n", $existing_root_cron_jobs)) {
@@ -1036,7 +1061,9 @@
         exec('crontab -u getmail -l > crontab.txt');
         $existing_cron_jobs = file('crontab.txt');
      
         $cron_jobs = array('*/5 * * * * '.$cf['program'].' -g '.$cf['config_dir'].' -r '.$cf['config_dir'].'/*.conf > /dev/null');
         $cron_jobs = array(
                '*/5 * * * * '.$cf['program'].' -g '.$cf['config_dir'].' -r '.$cf['config_dir'].'/*.conf > /dev/null 2>> /var/log/ispconfig/cron.log'
            );
      
         // remove existing ispconfig cronjobs, in case the syntax has changed
         foreach($cron_jobs as $key => $val) {