From 99d85e6fa76ecd354b9af64b5094b06058c801c7 Mon Sep 17 00:00:00 2001
From: tbrehm <t.brehm@ispconfig.org>
Date: Sat, 11 Aug 2007 13:11:41 +0000
Subject: [PATCH] Added mydns configuration to the installer.

---
 install/install.php                |  7 +++-
 install/lib/installer_base.lib.php | 19 +++++++++++
 install/tpl/mydns.conf.master      | 53 ++++++++++++++++++++++++++++++
 install/update.php                 |  7 +++-
 4 files changed, 84 insertions(+), 2 deletions(-)
 create mode 100644 install/tpl/mydns.conf.master

diff --git a/install/install.php b/install/install.php
index 05fba1fd31..3e0eb41097 100644
--- a/install/install.php
+++ b/install/install.php
@@ -90,10 +90,14 @@ $inst->configure_amavis();
 swriteln('Configuring Getmail');
 $inst->configure_getmail();
 
-// Configure Getmail
+// Configure Pureftpd
 swriteln('Configuring Pureftpd');
 $inst->configure_pureftpd();
 
+// Configure MyDNS
+swriteln('Configuring MyDNS');
+$inst->configure_mydns();
+
 // Configure ISPConfig
 swriteln('Installing ISPConfig');
 $inst->install_ispconfig();
@@ -128,6 +132,7 @@ system("/etc/init.d/courier-pop restart");
 system("/etc/init.d/courier-pop-ssl restart");
 system("/etc/init.d/apache2 restart");
 system("/etc/init.d/pure-ftpd-mysql restart");
+system("/etc/init.d/mydns restart");
 
 echo "Installation finished.\n";
 
diff --git a/install/lib/installer_base.lib.php b/install/lib/installer_base.lib.php
index ed9153a34b..335a497433 100644
--- a/install/lib/installer_base.lib.php
+++ b/install/lib/installer_base.lib.php
@@ -473,6 +473,25 @@ maildrop  unix  -       n       n       -       -       pipe
 	
 	}
 	
+	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;
diff --git a/install/tpl/mydns.conf.master b/install/tpl/mydns.conf.master
new file mode 100644
index 0000000000..4828cc1e9e
--- /dev/null
+++ b/install/tpl/mydns.conf.master
@@ -0,0 +1,53 @@
+## AUTOMATICALLY GENERATED BY DEBCONF. DO NOT MODIFY DATABASE
+## INFORMATION (database, db-*)...
+## PLEASE RUN 'dpkg-reconfigure mydns-mysql' INSTEAD.
+## CHANGES TO THE FOLLOWING DIRECTIVES ARE NOT PRESERVED, BUT REPLACED,
+## ON UPGRADE:
+##  user, group, pidfile, db-*, database
+
+##
+##  /etc/mydns.conf
+##  Thu Aug  2 16:36:26 2007
+##  For more information, see mydns.conf(5).
+##
+
+
+                                # DATABASE INFORMATION
+
+db-host = {mysql_server_ip}             # SQL server hostname
+db-user = {mysql_server_ispconfig_user}             # SQL server username
+db-password = {mysql_server_ispconfig_password}         # SQL server password
+database = {mysql_server_database}          # MyDNS database name
+
+
+                                # GENERAL OPTIONS
+
+user = nobody                   # Run with the permissions of this user
+group = nogroup                 # Run with the permissions of this group
+listen = *                      # Listen on these addresses ('*' for all)
+no-listen =                     # Do not listen on these addresses
+
+
+                                # CACHE OPTIONS
+
+zone-cache-size = 2048  # Maximum number of elements stored in the zone cache
+zone-cache-expire = 60  # Number of seconds after which cached zones expires
+reply-cache-size = 2048 # Maximum number of elements stored in the reply cache
+reply-cache-expire = 30 # Number of seconds after which cached replies expire
+
+
+                                # ESOTERICA
+
+log = LOG_DAEMON        # Facility to use for program output (LOG_*/stdout/stderr)
+pidfile = /var/run/mydns.pid    # Path to PID file
+timeout = 120   # Number of seconds after which queries time out
+multicpu = 1    # Number of CPUs installed on your system
+recursive =                     # Location of recursive resolver
+allow-axfr = yes # Should AXFR be enabled?
+allow-tcp = no  # Should TCP be enabled?
+allow-update = no       # Should DNS UPDATE be enabled?
+ignore-minimum = no     # Ignore minimum TTL for zone?
+soa-table = dns_soa     # Name of table containing SOA records
+rr-table = dns_rr       # Name of table containing RR data
+soa-where = server_id = {server_id}               # Extra WHERE clause for SOA queries
+rr-where =  server_id = {server_id}               # Extra WHERE clause for RR queries
\ No newline at end of file
diff --git a/install/update.php b/install/update.php
index 66deec92c4..47b9945ee7 100644
--- a/install/update.php
+++ b/install/update.php
@@ -128,10 +128,14 @@ $inst->configure_amavis();
 swriteln('Configuring Getmail');
 $inst->configure_getmail();
 
-// Configure Getmail
+// Configure Pureftpd
 swriteln('Configuring Pureftpd');
 $inst->configure_pureftpd();
 
+// Configure MyDNS
+swriteln('Configuring MyDNS');
+$inst->configure_mydns();
+
 // Configure ISPConfig
 swriteln('Installing ISPConfig');
 $inst->install_ispconfig();
@@ -158,6 +162,7 @@ system("/etc/init.d/courier-pop restart");
 system("/etc/init.d/courier-pop-ssl restart");
 system("/etc/init.d/apache2 restart");
 system("/etc/init.d/pure-ftpd-mysql restart");
+system("/etc/init.d/mydns restart");
 
 echo "Update finished.\n";
 
-- 
GitLab