From 239ce82f07a17a0214db0198d5fcb26e2683d89d Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sat, 11 Aug 2007 11:08:25 -0400
Subject: [PATCH] 

---
 install/lib/installer_base.lib.php |   84 ++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 80 insertions(+), 4 deletions(-)

diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index cd7e699..c7bf3fd 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -38,13 +38,68 @@
 	
 	*/
 	
-	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);
+			swrite($this->lng($query).' ('.$answers_str.') ['.$default.']: ');
+			$input = sread();
+			
+			// Stop the installation
+			if($input == 'quit') {
+				swriteln($this->lng('Installation interrupted.'));
+				die();
+			}
+			
+			// Select the default
+			if($input == '') {
+				$answer = $default;
+				$finished = true;
+			}
+			
+			if(in_array($input,$answers)) {
+				$answer = $input;
+				$finished = true;
+			}
+			
+		} while ($finished == false);
+		swriteln();
+		return $answer;
+	}
+	
+	function free_query($query,$default) {
+		global $conf;
+		
+		swrite($this->lng($query).' ['.$default.']: ');
+		$input = sread();
+			
+		// Stop the installation
+		if($input == 'quit') {
+			swriteln($this->lng('Installation interrupted.'));
+			die();
+		}
+			
+		// Select the default
+		if($input == '') {
+			$answer = $default;
+		} else {
+			$answer = $input;
+		}
+		swriteln();
+		
+		return $answer;
+	}
+	
 	
 	function request_language() {
 		
@@ -248,7 +303,7 @@
   flags=R user=vmail argv=/usr/bin/maildrop -d ${recipient} ${extension} ${recipient} ${user} ${nexthop} ${sender}
 		
 		*/
-		if(stristr($options,'dont-create-certs')) {
+		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);
@@ -473,6 +528,25 @@
 	
 	}
 	
+	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_host}',$conf["mysql_server_host"],$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;
@@ -544,7 +618,9 @@
 		// 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
-		exec('ln -s '.$conf["dist_apache_vhost_conf_dir"].'/ispconfig.vhost '.$conf["dist_apache_vhost_conf_enabled_dir"].'/ispconfig.vhost');
+		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');
+		}
 		
 	}
 	

--
Gitblit v1.9.1