vogelor
2010-05-01 abdc67d2c6a8d1978ae2180b357993d9aefbcd01
install/lib/installer_base.lib.php
@@ -38,25 +38,21 @@
   public $is_update = false; // true if it is an update, falsi if it is a new install
    public function __construct()
    {
   public function __construct() {
        global $conf; //TODO: maybe $conf  should be passed to constructor
        //$this->conf = $conf;
    }
   
    //: TODO  Implement the translation function and language files for the installer.
   public function lng($text)
    {
   public function lng($text) {
      return $text;
   }
   
   public function error($msg)
    {
   public function error($msg) {
      die("ERROR: ".$msg."\n");
   }
   
   public function simple_query($query, $answers, $default)
    {
   public function simple_query($query, $answers, $default) {
      $finished = false;
      do {
         $answers_str = implode(',', $answers);
@@ -86,8 +82,7 @@
      return $answer;
   }
   
   public function free_query($query,$default)
    {
   public function free_query($query,$default) {
      swrite($this->lng($query).' ['.$default.']: ');
      $input = sread();
         
@@ -264,8 +259,7 @@
      
   }
   
    public function grant_master_database_rights()
    {
   public function grant_master_database_rights() {
        global $conf;
        
        if($conf['mysql']['master_slave_setup'] != 'y') return;
@@ -367,8 +361,7 @@
    }
    //** writes postfix configuration files
    public function process_postfix_config($configfile)
    {
   public function process_postfix_config($configfile) {
      global $conf;
      
        $config_dir = $conf['postfix']['config_dir'].'/';
@@ -386,8 +379,7 @@
        wf($full_file_name, $content);
    }
   public function configure_jailkit()
    {
   public function configure_jailkit() {
        global $conf;
      
      $cf = $conf['jailkit'];
@@ -395,8 +387,7 @@
      $jk_init = $cf['jk_init'];
      $jk_chrootsh = $cf['jk_chrootsh'];
      
      if (is_dir($config_dir))
      {
      if (is_dir($config_dir)) {
         if(is_file($config_dir.'/'.$jk_init)) copy($config_dir.'/'.$jk_init, $config_dir.'/'.$jk_init.'~');
         if(is_file($config_dir.'/'.$jk_chrootsh.".master")) copy($config_dir.'/'.$jk_chrootsh.".master", $config_dir.'/'.$jk_chrootsh.'~');
         
@@ -406,8 +397,7 @@
      
    }
        
   public function configure_postfix($options = '')
    {
   public function configure_postfix($options = '') {
        global $conf;
      $cf = $conf['postfix'];
      $config_dir = $cf['config_dir'];
@@ -612,8 +602,7 @@
      
   }
   
   public function configure_pam()
    {
   public function configure_pam() {
      global $conf;
      $pam = $conf['pam'];
      //* configure pam for SMTP authentication agains the ispconfig database
@@ -632,8 +621,7 @@
   
   }
   
   public function configure_courier()
    {
   public function configure_courier() {
      global $conf;
      $config_dir = $conf['courier']['config_dir'];
      //* authmysqlrc
@@ -665,8 +653,7 @@
      wf($configfile, $content);
   }
   
   public function configure_dovecot()
    {
   public function configure_dovecot() {
      global $conf;
      
      $config_dir = $conf['dovecot']['config_dir'];
@@ -781,8 +768,7 @@
      
   }
   
   public function configure_spamassassin()
    {
   public function configure_spamassassin() {
      global $conf;
      
      //* Enable spamasasssin on debian and ubuntu
@@ -795,8 +781,7 @@
      wf($configfile, $content);
   }
   
   public function configure_getmail()
    {
   public function configure_getmail() {
      global $conf;
      
      $config_dir = $conf['getmail']['config_dir'];
@@ -814,8 +799,7 @@
   }
   
   
   public function configure_pureftpd()
    {
   public function configure_pureftpd() {
      global $conf;
      
      $config_dir = $conf['pureftpd']['config_dir'];
@@ -855,8 +839,7 @@
      if(!is_file('/etc/pure-ftpd/conf/DontResolve')) exec("echo 'yes' > /etc/pure-ftpd/conf/DontResolve");
   }
   
   public function configure_mydns()
    {
   public function configure_mydns() {
      global $conf;
      
      // configure pam for SMTP authentication agains the ispconfig database
@@ -926,8 +909,7 @@
   
   
   
   public function configure_apache()
    {
   public function configure_apache() {
      global $conf;
      
      //* Create the logging directory for the vhost logfiles
@@ -990,8 +972,7 @@
      
   }
   
   public function configure_firewall()
   {
   public function configure_firewall() {
      global $conf;
      
      $dist_init_scripts = $conf['init_scripts'];
@@ -1051,8 +1032,7 @@
   }
   
    public function configure_vlogger()
    {
   public function configure_vlogger() {
        global $conf;
        
        //** Configure vlogger to use traffic logging to mysql (master) db
@@ -1077,8 +1057,7 @@
    
    }
   
   public function configure_apps_vhost()
   {
   public function configure_apps_vhost() {
      global $conf;
      
      //* Create the ispconfig apps vhost user and group
@@ -1142,8 +1121,7 @@
   
   }
    
   public function install_ispconfig()
    {
   public function install_ispconfig() {
      global $conf;
      
      $install_dir = $conf['ispconfig_install_dir'];
@@ -1218,9 +1196,12 @@
      
      wf("$install_dir/server/lib/$configfile", $content);
      //* Create the config file for remote-actions
      $content = "<?php\n$maxid_remote_actions = 1;\n?>";
      wf("$install_dir/server/lib/remote_actions.inc.php", $content);
      //* Create the config file for remote-actions (but only, if it does not exist, because
      //  the value is a autoinc-value and so changed by the remoteaction_core_module
      if (!file_exists("$install_dir/server/lib/remote_action.inc.php")) {
         $content = '<?php' . "\n" . '$maxid_remote_action = 0;' . "\n?>";
         wf("$install_dir/server/lib/remote_action.inc.php", $content);
      }
      
      //* Enable the server modules and plugins.
      // TODO: Implement a selector which modules and plugins shall be enabled.
@@ -1323,8 +1304,8 @@
      exec("chmod 600 $install_dir/server/lib/$configfile");
      exec("chown root:root $install_dir/server/lib/$configfile");
      exec("chmod 600 $install_dir/server/lib/remote_actions.inc.php");
      exec("chown root:root $install_dir/server/lib/remote_actions.inc.php");
      exec("chmod 600 $install_dir/server/lib/remote_action.inc.php");
      exec("chown root:root $install_dir/server/lib/remote_action.inc.php");
      if(@is_file("$install_dir/server/lib/mysql_clientdb.conf")) {
         exec("chmod 600 $install_dir/server/lib/mysql_clientdb.conf");
@@ -1426,8 +1407,7 @@
      }
   }
   
   public function configure_dbserver()
   {
   public function configure_dbserver() {
      global $conf;
      
      //* If this server shall act as database server for client DB's, we configure this here
@@ -1450,8 +1430,7 @@
      
   }
   
   public function install_crontab()
    {
   public function install_crontab() {
      global $conf;
      
      //* Root Crontab
@@ -1521,8 +1500,7 @@
    * @param bool $tDBCred
    * @return string Relative path to the chosen template file
    */
   protected function get_template_file($tLocal, $tRf=false, $tDBCred=false)
   {
   protected function get_template_file($tLocal, $tRf=false, $tDBCred=false) {
      global $conf, $dist;
      
      $final_path = '';
@@ -1553,11 +1531,9 @@
    * @param $tContents
    * @return bool
    */
   protected function write_config_file($tConf, $tContents)
   {
   protected function write_config_file($tConf, $tContents) {
      // Backup config file before writing new contents and stat file
      if ( is_file($tConf) )
      {
      if ( is_file($tConf) ) {
         $stat = exec('stat -c \'%a %U %G\' '.escapeshellarg($tConf), $output, $res);
         if ($res == 0) { // stat successfull
            list($access, $user, $group) = split(" ", $stat);
@@ -1606,8 +1582,7 @@
    * @param $tContents
    * @return string
    */
   protected function insert_db_credentials($tContents)
   {
   protected function insert_db_credentials($tContents) {
      global $conf;
      
      $tContents = str_replace('{mysql_server_ispconfig_user}', $conf["mysql"]["ispconfig_user"], $tContents);