tbrehm
2007-08-11 ce95440aa1c20dd7aa169d9ac8b1d5db3889b467
install/lib/installer_base.lib.php
@@ -38,13 +38,63 @@
   
   */
   
   function lng() {
   function lng($text) {
      return $text;
   }
   
   function error($msg) {
      die("ERROR: ".$msg."\n");
   }
   function simple_query($query,$answers,$default) {
      global $conf;
      $finished = false;
      do {
         $answers_str = implode(",",$answers);
         swriteln($this->lng($query).' ('.$answers_str.') ['.$default.']:');
         $input = sread();
         // Stop the installation
         if($input == 'quit') {
            die($this->lng('Installation interrupted.'));
         }
         // Select the default
         if($input == '') {
            $answer = $default;
            $finished = true;
         }
         if(in_array($input,$answers)) {
            $answer = $input;
            $finished = true;
         }
      } while ($finished == false);
      return $answer;
   }
   function free_query($query,$default) {
      global $conf;
      $answers_str = implode(",",$answers);
      swriteln($this->lng($query).' ['.$default.']:');
      $input = sread();
      // Stop the installation
      if($input == 'quit') {
         die($this->lng('Installation interrupted.'));
      }
      // Select the default
      if($input == '') {
         $answer = $default;
      }
      return $answer;
   }
   
   function request_language() {
      
@@ -104,7 +154,7 @@
      Create postfix configuration files
   */
   
   function configure_postfix() {
   function configure_postfix($options = '') {
      global $conf;
      
      if(!is_dir($conf["dist_postfix_config_dir"])) $this->error("The postfix configuration directory ".$conf["dist_postfix_config_dir"]." does not exist.");
@@ -248,13 +298,14 @@
  flags=R user=vmail argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}
      
      */
      if(!stristr($options,'dont-create-certs')) {
         // Create the SSL certificate
         $command = "cd ".$conf["dist_postfix_config_dir"]."; openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509";
         exec($command);
      
      // Create the SSL certificate
      $command = "cd ".$conf["dist_postfix_config_dir"]."; openssl req -new -outform PEM -out smtpd.cert -newkey rsa:2048 -nodes -keyout smtpd.key -keyform PEM -days 365 -x509";
      exec($command);
      $command = "chmod o= ".$conf["dist_postfix_config_dir"]."/smtpd.key";
      caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
         $command = "chmod o= ".$conf["dist_postfix_config_dir"]."/smtpd.key";
         caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
      }
      
      /*
      We have to change the permissions of the courier authdaemon directory
@@ -318,7 +369,7 @@
      // Edit the file /etc/default/saslauthd
      $configfile = '/etc/default/saslauthd';
      if(is_file($configfile)) copy($configfile,$configfile.'~');
      if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'/~');
      if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~');
      $content = rf($configfile);
      $content = str_replace('START=no','START=yes',$content);
      $content = str_replace('OPTIONS="-c"','OPTIONS="-m /var/spool/postfix/var/run/saslauthd -r"',$content);
@@ -371,7 +422,7 @@
      //authdaemonrc
      $configfile = $conf["dist_courier_config_dir"].'/authdaemonrc';
      if(is_file($configfile)) copy($configfile,$configfile.'~');
      if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'/~');
      if(is_file($configfile.'~')) exec('chmod 400 '.$configfile.'~');
      $content = rf($configfile);
      $content = str_replace('authmodulelist="authpam"','authmodulelist="authmysql"',$content);
      wf($configfile,$content);
@@ -451,6 +502,47 @@
   }
   
   
   function configure_pureftpd() {
      global $conf;
      // configure pam for SMTP authentication agains the ispconfig database
      $configfile = 'mysql.conf';
      if(is_file($conf["dist_pureftpd_config_dir"].'/'.$configfile)) copy($conf["dist_pureftpd_config_dir"].'/'.$configfile,$conf["dist_pureftpd_config_dir"].'/'.$configfile.'~');
      if(is_file($conf["dist_pureftpd_config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["dist_pureftpd_config_dir"].'/'.$configfile.'~');
      $content = rf("tpl/pureftpd_".$configfile.".master");
      $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
      $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
      $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
      $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
      $content = str_replace('{server_id}',$conf["server_id"],$content);
      wf($conf["dist_pureftpd_config_dir"].'/'.$configfile,$content);
      exec('chmod 600 '.$conf["dist_pureftpd_config_dir"].'/'.$configfile);
      exec('chown root:root '.$conf["dist_pureftpd_config_dir"].'/'.$configfile);
      // enable chrooting
      exec('echo "yes" > /etc/pure-ftpd/conf/ChrootEveryone');
   }
   function configure_mydns() {
      global $conf;
      // configure pam for SMTP authentication agains the ispconfig database
      $configfile = 'mydns.conf';
      if(is_file($conf["dist_mydns_config_dir"].'/'.$configfile)) copy($conf["dist_mydns_config_dir"].'/'.$configfile,$conf["dist_mydns_config_dir"].'/'.$configfile.'~');
      if(is_file($conf["dist_mydns_config_dir"].'/'.$configfile.'~')) exec('chmod 400 '.$conf["dist_mydns_config_dir"].'/'.$configfile.'~');
      $content = rf("tpl/".$configfile.".master");
      $content = str_replace('{mysql_server_ispconfig_user}',$conf["mysql_server_ispconfig_user"],$content);
      $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
      $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
      $content = str_replace('{mysql_server_ip}',$conf["mysql_server_ip"],$content);
      $content = str_replace('{server_id}',$conf["server_id"],$content);
      wf($conf["dist_mydns_config_dir"].'/'.$configfile,$content);
      exec('chmod 600 '.$conf["dist_mydns_config_dir"].'/'.$configfile);
      exec('chown root:root '.$conf["dist_mydns_config_dir"].'/'.$configfile);
   }
   function install_ispconfig() {
      global $conf;
      
@@ -495,6 +587,7 @@
      $content = str_replace('{mysql_server_ispconfig_password}',$conf["mysql_server_ispconfig_password"],$content);
      $content = str_replace('{mysql_server_database}',$conf["mysql_server_database"],$content);
      $content = str_replace('{mysql_server_host}',$conf["mysql_server_host"],$content);
      $content = str_replace('{server_id}',$conf["server_id"],$content);
      wf($conf["ispconfig_install_dir"].'/server/lib/'.$configfile,$content);
      
      
@@ -517,6 +610,13 @@
      $command = "chmod +x ".$conf["ispconfig_install_dir"]."/server/scripts/*.sh";
      caselog($command." &> /dev/null", __FILE__, __LINE__,"EXECUTED: ".$command,"Failed to execute the command ".$command);
      
      // Copy the ISPConfig vhost for the controlpanel
      copy('tpl/apache_ispconfig.vhost.master',$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost');
      // and create the symlink
      if(!is_link($conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost')) {
         exec('ln -s '.$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost '.$conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost');
      }
   }
   
   function install_crontab() {