tbrehm
2012-04-05 aad3f0eb1e40aff62e888bff45d193ce0838f90c
install/lib/installer_base.lib.php
@@ -158,10 +158,10 @@
         $this->error('Stopped: Database already contains some tables.');
      } else {
         if($conf['mysql']['admin_password'] == '') {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
            caselog("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." ".escapeshellarg($conf['mysql']['database'])." < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                  __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
         } else {
            caselog("mysql --default-character-set=".$conf['mysql']['charset']." -h '".$conf['mysql']['host']."' -u '".$conf['mysql']['admin_user']."' -p'".$conf['mysql']['admin_password']."' '".$conf['mysql']['database']."' < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
            caselog("mysql --default-character-set=".escapeshellarg($conf['mysql']['charset'])." -h ".escapeshellarg($conf['mysql']['host'])." -u ".escapeshellarg($conf['mysql']['admin_user'])." -p".escapeshellarg($conf['mysql']['admin_password'])." ".escapeshellarg($conf['mysql']['database'])." < '".ISPC_INSTALL_ROOT."/install/sql/ispconfig3.sql' &> /dev/null",
                  __FILE__, __LINE__, 'read in ispconfig3.sql', 'could not read in ispconfig3.sql');
         }
         $db_tables = $this->db->getTables();
@@ -514,6 +514,10 @@
         copy('tpl/'.$jk_init.'.master', $config_dir.'/'.$jk_init);
         copy('tpl/'.$jk_chrootsh.'.master', $config_dir.'/'.$jk_chrootsh);
      }
      //* help jailkit fo find its ini files
      if(!is_link('/usr/jk_socketd.ini')) exec('ln -s /etc/jailkit/jk_socketd.ini /usr/jk_socketd.ini');
      if(!is_link('/usr/jk_init.ini')) exec('ln -s /etc/jailkit/jk_init.ini /usr/jk_init.ini');
   }
   
@@ -624,11 +628,9 @@
      $command = 'useradd -g '.$cf['vmail_groupname'].' -u '.$cf['vmail_userid'].' '.$cf['vmail_username'].' -d '.$cf['vmail_mailbox_base'].' -m';
      if(!is_user($cf['vmail_username'])) caselog("$command &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
      //* These postconf commands will be executed on installation and update
      $postconf_commands = array (
            'myhostname = '.$conf['hostname'],
            'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain',
            'mynetworks = 127.0.0.0/8 [::1]/128',
            'alias_maps = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases',
            'alias_database = hash:/etc/aliases, hash:/var/lib/mailman/data/aliases',
            'virtual_alias_domains =',
@@ -662,6 +664,15 @@
            'body_checks = regexp:'.$config_dir.'/body_checks',
            'owner_request_special = no'
      );
      //* These postconf commands will be executed on installation only
      if($this->is_update == false) {
         $postconf_commands = array_merge($postconf_commands,array(
            'myhostname = '.$conf['hostname'],
            'mydestination = '.$conf['hostname'].', localhost, localhost.localdomain',
            'mynetworks = 127.0.0.0/8 [::1]/128'
         ));
      }
      //* Create the header and body check files
      touch($config_dir.'/header_checks');
@@ -876,19 +887,32 @@
         caselog($command." &> /dev/null", __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
      }
      //* copy dovecot.conf
      //* backup dovecot.conf
      $configfile = 'dovecot.conf';
      if(is_file($config_dir.'/'.$configfile)) {
         copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
      }
      copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile);
      //* Get the dovecot version
      exec('dovecot --version',$tmp);
      $parts = explode('.',trim($tmp[0]));
      $dovecot_version = $parts[0];
      unset($tmp);
      unset($parts);
      //* Copy dovecot configuration file
      if($dovecot_version == 2) {
         copy('tpl/debian_dovecot2.conf.master',$config_dir.'/'.$configfile);
      } else {
         copy('tpl/debian_dovecot.conf.master',$config_dir.'/'.$configfile);
      }
      //* dovecot-sql.conf
      $configfile = 'dovecot-sql.conf';
      if(is_file($config_dir.'/'.$configfile)) {
         copy($config_dir.'/'.$configfile, $config_dir.'/'.$configfile.'~');
      }
      chmod($config_dir.'/'.$configfile.'~', 0400);
      if(is_file($config_dir.'/'.$configfile.'~')) chmod($config_dir.'/'.$configfile.'~', 0400);
      $content = rf('tpl/debian_dovecot-sql.conf.master');
      $content = str_replace('{mysql_server_ispconfig_user}',$conf['mysql']['ispconfig_user'],$content);
      $content = str_replace('{mysql_server_ispconfig_password}',$conf['mysql']['ispconfig_password'], $content);
@@ -1459,7 +1483,11 @@
         $command = 'adduser '.$conf['nginx']['user'].' '.$apps_vhost_group;
         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         if(!@is_dir($install_dir)) mkdir($install_dir, 0755, true);
         if(!@is_dir($install_dir)){
            mkdir($install_dir, 0755, true);
         } else {
            chmod($install_dir, 0755);
         }
         chown($install_dir, $apps_vhost_user);
         chgrp($install_dir, $apps_vhost_group);
@@ -1481,6 +1509,7 @@
         if(substr($socket_dir,-1) != '/') $socket_dir .= '/';
         if(!is_dir($socket_dir)) exec('mkdir -p '.$socket_dir);
         $fpm_socket = $socket_dir.'apps.sock';
         $cgi_socket = escapeshellcmd($conf['nginx']['cgi_socket']);
         $content = str_replace('{apps_vhost_ip}', $apps_vhost_ip, $content);
         $content = str_replace('{apps_vhost_port}', $conf['web']['apps_vhost_port'], $content);
@@ -1488,6 +1517,7 @@
         $content = str_replace('{apps_vhost_servername}', $apps_vhost_servername, $content);
         //$content = str_replace('{fpm_port}', ($conf['nginx']['php_fpm_start_port']+1), $content);
         $content = str_replace('{fpm_socket}', $fpm_socket, $content);
         $content = str_replace('{cgi_socket}', $cgi_socket, $content);
         wf($vhost_conf_dir.'/apps.vhost', $content);
         
@@ -1583,6 +1613,7 @@
      $content = str_replace('{server_id}', $conf['server_id'], $content);
      $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
      $content = str_replace('{language}', $conf['language'], $content);
      $content = str_replace('{timezone}', $conf['timezone'], $content);
      wf($install_dir.'/interface/lib/'.$configfile, $content);
@@ -1605,6 +1636,7 @@
      $content = str_replace('{server_id}', $conf['server_id'], $content);
      $content = str_replace('{ispconfig_log_priority}', $conf['ispconfig_log_priority'], $content);
      $content = str_replace('{language}', $conf['language'], $content);
      $content = str_replace('{timezone}', $conf['timezone'], $content);
      wf($install_dir.'/server/lib/'.$configfile, $content);
@@ -1679,13 +1711,9 @@
      $dns_server_enabled = ($conf['services']['dns'])?1:0;
      $file_server_enabled = ($conf['services']['file'])?1:0;
      $db_server_enabled = ($conf['services']['db'])?1:0;
      $vserver_server_enabled = ($conf['services']['vserver'])?1:0;
      $vserver_server_enabled = ($conf['openvz']['installed'])?1:0;
      $proxy_server_enabled = ($conf['services']['proxy'])?1:0;
      $firewall_server_enabled = ($conf['services']['firewall'])?1:0;
      $sql = "UPDATE `server` SET mail_server = '$mail_server_enabled', web_server = '$web_server_enabled', dns_server = '$dns_server_enabled', file_server = '$file_server_enabled', db_server = '$db_server_enabled', vserver_server = '$vserver_server_enabled', proxy_server = '$proxy_server_enabled', firewall_server = '$firewall_server_enabled' WHERE server_id = ".intval($conf['server_id']);
@@ -1741,6 +1769,12 @@
         chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
         chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
      }
      if(is_dir($install_dir.'/interface/invoices')) {
         chmod($install_dir.'/interface/invoices', 0770);
         chown($install_dir.'/interface/invoices', 'ispconfig');
         chgrp($install_dir.'/interface/invoices', 'ispconfig');
      }
      // TODO: FIXME: add the www-data user to the ispconfig group. This is just for testing
      // and must be fixed as this will allow the apache user to read the ispconfig files.
@@ -1748,14 +1782,18 @@
      if($conf['apache']['installed'] == true){
         $command = 'adduser '.$conf['apache']['user'].' ispconfig';
         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         $command = 'adduser '.$conf['apache']['user'].' ispapps';
         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         if(is_group('ispapps')){
            $command = 'adduser '.$conf['apache']['user'].' ispapps';
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         }
      }
      if($conf['nginx']['installed'] == true){
         $command = 'adduser '.$conf['nginx']['user'].' ispconfig';
         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         $command = 'adduser '.$conf['nginx']['user'].' ispapps';
         caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         if(is_group('ispapps')){
            $command = 'adduser '.$conf['nginx']['user'].' ispapps';
            caselog($command.' &> /dev/null', __FILE__, __LINE__, "EXECUTED: $command", "Failed to execute the command $command");
         }
      }
      //* Make the shell scripts executable
@@ -1931,7 +1969,7 @@
      wf($install_dir.'/server/lib/mysql_clientdb.conf',$content);
      chmod($install_dir.'/server/lib/mysql_clientdb.conf', 0600);
      chown($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
      chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
      chgrp($install_dir.'/server/lib/mysql_clientdb.conf', 'root');
   }