From 502ff8391041957c61f9ae270c692c17e00f4271 Mon Sep 17 00:00:00 2001
From: Purodha Blissenbach <purodha.blissenbach@hostsharing.net>
Date: Thu, 20 Sep 2012 20:25:17 +0200
Subject: [PATCH] Merge branch 'master' of ssh://hsh04-source@hsh04.hostsharing.net/home/doms/source.hostsharing.net/source/hsadmin.git

---
 hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl     |   13 ++++--
 hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java    |   38 ++++++-------------
 hsarback/src/de/hsadmin/mods/dom/index.html.jtpl             |    4 +-
 hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl    |   14 ++++--
 hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java |    6 +-
 5 files changed, 34 insertions(+), 41 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
index d5ef673..7572ddd 100644
--- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -311,10 +311,10 @@
 		}
 		Processor domSetupProcessor = new CompoundProcessor(
 			createDomainDirectoriesProcessor(dom, templateVars),
-			new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-available/" + domName + ".tmp", "root", "root", "644", true),
+			new CreateFileProcessor(selectVHostTemplate(dom), templateVars, iterateMaps.iterator(), "/etc/apache2/sites-available/" + domName + ".tmp", "root", "root", "644", true),
 			new ShellProcessor("ls /etc/apache2/pems/" + pac + ".pem >/dev/null 2>&1 " +
-					" && sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/sites-available/" + domName + ".tmp" + 
-					" && (ls /etc/apache2/pems/" + pac + ".chain.pem >/dev/null 2>&1 || sed -i '/SSLCertificateChain.*" + pac + "/d' " + "/etc/apache2/sites-available/" + domName + ".tmp)" + 
+					"&& sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/sites-available/" + domName + ".tmp" + 
+					" && (ls /etc/apache2/pems/" + pac + ".chain.pem >/dev/null 2>&1 || sed -i '/SSLCertificateChain.*" + pac + "/d' " + "/etc/apache2/sites-available/" + domName + ".tmp )" + 
 					" || sed -i '/SSLCertificate.*" + pac + "/d' " + "/etc/apache2/sites-available/" + domName + ".tmp"),
 			new ShellProcessor(
 					" (diff -q /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName + " && rm /etc/apache2/sites-available/" + domName + ".tmp ) " +
diff --git a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl b/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl
index 7ff5764..e8d7af6 100644
--- a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl
+++ b/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl
@@ -7,7 +7,7 @@
 
     ServerName {DOM_HOSTNAME}
     ServerAlias *.{DOM_HOSTNAME}
-    ServerAdmin {DOM_USERNAME}@{HIVE}.hostsharing.net
+    ServerAdmin webmaster@{DOM_HOSTNAME}
 
     SuexecUserGroup {DOM_USERNAME} {PAC}
 
@@ -24,15 +24,15 @@
        AllowOverride AuthConfig FileInfo Indexes Limit
     </Directory>
 
-    <Location /cgi-bin/>
+    <Directory /home/doms/{DOM_HOSTNAME}/cgi-bin/>
         SetHandler cgi-script
         Options +ExecCGI -Indexes -MultiViews
-    </Location>
+    </Directory>
 
-    <Location /fastcgi-bin/>
+    <Directory /home/doms/{DOM_HOSTNAME}/fastcgi-bin/>
         SetHandler fcgid-script
         Options +ExecCGI -Indexes -MultiViews
-    </Location>
+    </Directory>
 
     RewriteEngine On
     RewriteOptions Inherit
@@ -42,12 +42,14 @@
     RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
     RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d
     RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last]
+    
 <!-- BEGIN: iterate -->
     RewriteCond %{REQUEST_URI} !^/cgi-bin/
     RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
     RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
     RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d
     RewriteRule ^(.*) - [redirect=404,last]
+
 <!-- END: iterate -->
     AddType application/x-httpd-php .php .php5 .php4 .php3
     Action application/x-httpd-php /fastcgi-bin/phpstub
@@ -100,12 +102,14 @@
     RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:443)?$ [novary]
     RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} -d
     RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1}$1 [last]
+    
 <!-- BEGIN: nosubdomainfallbackforhttps -->
     RewriteCond %{REQUEST_URI} !^/cgi-bin/
     RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
     RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:443)?$ [novary]
     RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} !-d
     RewriteRule ^(.*) - [redirect=404,last]
+    
 <!-- END: nosubdomainfallbackforhttps -->
     AddType application/x-httpd-php .php .php5 .php4 .php3
     Action application/x-httpd-php /fastcgi-bin/phpstub
diff --git a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl b/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl
index 0f0cc6e..4a2cb1c 100644
--- a/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl
+++ b/hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl
@@ -7,7 +7,7 @@
 
     ServerName {DOM_HOSTNAME}
     ServerAlias *.{DOM_HOSTNAME}
-    ServerAdmin {DOM_USERNAME}@{HIVE}.hostsharing.net
+    ServerAdmin webmaster@{DOM_HOSTNAME}
 
     SuexecUserGroup {DOM_USERNAME} {PAC}
 
@@ -21,13 +21,13 @@
        AllowOverride AuthConfig FileInfo Indexes Limit
     </Directory>
 
-    <Location /cgi-bin/>
+    <Directory /home/doms/{DOM_HOSTNAME}/cgi-bin/>
         Redirect 501 /
-    </Location>
+    </Directory>
 
-    <Location /fastcgi-bin/>
+    <Directory /home/doms/{DOM_HOSTNAME}/fastcgi-bin/>
         Redirect 501 /
-    </Location>
+    </Directory>
 
     RewriteEngine On
     RewriteOptions Inherit
@@ -35,9 +35,11 @@
     RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
     RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} -d
     RewriteRule ^(.*) /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1}$1 [last]
+    
 <!-- BEGIN: iterate -->    RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:80)?$ [novary]
     RewriteCond /home/doms/{DOM_HOSTNAME}/subs/${tolower:%1} !-d
     RewriteRule ^(.*) - [redirect=404,last]
+    
 <!-- END: iterate -->
 </VirtualHost>
 
@@ -84,6 +86,7 @@
 <!-- BEGIN: nosubdomainfallbackforhttps -->    RewriteCond %{HTTP_HOST} ^(.+)\.{DOM_HOSTNAME}\.?(:443)?$ [novary]
     RewriteCond /home/doms/{DOM_HOSTNAME}/subs-ssl/${tolower:%1} !-d
     RewriteRule ^(.*) - [redirect=404,last]
+    
 <!-- END: nosubdomainfallbackforhttps -->
 </VirtualHost>
 <!-- END: main -->
\ No newline at end of file
diff --git a/hsarback/src/de/hsadmin/mods/dom/index.html.jtpl b/hsarback/src/de/hsadmin/mods/dom/index.html.jtpl
index b55e909..08d1a9d 100644
--- a/hsarback/src/de/hsadmin/mods/dom/index.html.jtpl
+++ b/hsarback/src/de/hsadmin/mods/dom/index.html.jtpl
@@ -10,11 +10,11 @@
 
 <p>Diese neue Website wurde gerade bei der
 <a href="http://www.hostsharing.net">Hostsharing eG</a>
-f&uuml;r {USER_NAME} eingerichtet. </p>
+f&uuml;r {USER_NAME} eingerichtet.</p>
 
 <p>Der Inhaber der Domain ist bereits per Email unter
 <a href="mailto:webmaster(at){DOMAIN}">webmaster(at){DOMAIN}</a>
-zu erreichen. </p>
+zu erreichen.</p>
 
 </body>
 
diff --git a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
index d729873..f764792 100644
--- a/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/pac/PacProcessorFactory.java
@@ -29,13 +29,11 @@
 			EntityManager em, T entity) throws ProcessorException {
 		Pac pac = (Pac) entity;
 		String pacName = pac.getName();
-//		String customerEMail = pac.getCustomer().getContractualContact().getEmail();
 		Hive hive = pac.getHive();
 		UnixUser unixUser = getPacAdminUser(pac);
 		String password = PasswordTool.generatePassword();
 		Map<String, String> hiveValues = fillHiveValues(hive);
 		List<Map<String, String>> pacValuesList = fillPacValuesList(hive, null);
-//		Map<String, String> emailVars = fillEMailValues(pacName, customerEMail, password);
 		Processor priProcessor = new CompoundProcessor(
 				createAddUserProc(pacName, unixUser, password), 
 				createSetQuotaProc(pac),
@@ -46,10 +44,14 @@
 				createProftpdConfProc(hiveValues, pacValuesList), 
 				createMakePacDirectoryStructure(unixUser),
 				createIfUp(pacName),
-				createHttpdVirtualProc(pacName, pacValuesList));
+				createHttpdVirtualProc(pacName, pacValuesList),
+				createAccountingRulesProc());
 		WaitingTasksProcessor secProcessor = new WaitingTasksProcessor(priProcessor);
-//		secProcessor.appendProcessor(pac.getHiveName(), createSendEMailProc(pacName, customerEMail, emailVars), "send email to customer");
 		return secProcessor;
+	}
+
+	private Processor createAccountingRulesProc() {
+		return new ShellProcessor("mk-iptables-rules Accounting");
 	}
 
 	private Processor createHttpdVirtualProc(
@@ -58,8 +60,8 @@
 				new CreateFileProcessor("/de/hsadmin/mods/pac/httpd-virtual.jtpl", new HashMap<String, String>(), pacValuesList.iterator(), "/etc/apache2/virtual.conf.tmp", "root", "root", "644", true),
 				new ShellProcessor("ls /etc/apache2/pems/" + pacName + ".pem >/dev/null 2>&1 " + "&& sed -i '/SSLCertificate.*default/d' " + "/etc/apache2/apache.conf.tmp"
 								+ " && (ls /etc/apache2/pems/" + pacName + ".chain.pem >/dev/null 2>&1"
-								+ " || sed -i '/SSLCertificateChain.*" + pacName + "/d' "/etc/apache2/virtual.conf.tmp)"
-								+ " || sed -i '/SSLCertificate.*" + pacName"/d' " + "/etc/apache2/virtual.conf.tmp"),
+								+ " || sed -i '/SSLCertificateChain.*" + pacName + "/d' " + "/etc/apache2/virtual.conf.tmp)"
+								+ " || sed -i '/SSLCertificate.*" + pacName + "/d' " + "/etc/apache2/virtual.conf.tmp"),
 				new ShellProcessor("(diff -q /etc/apache2/apache.conf.tmp /etc/apache2/apache.conf"
 								+ " && rm /etc/apache2/apache.conf.tmp)"
 								+ " || invoke-rc.d apache2 reload >/dev/null 2>&1"));
@@ -85,7 +87,8 @@
 				createNetworkInterfacesProc(hiveValues, pacValuesList), 
 				createSudouersProc(hiveValues, pacValuesList), 
 				createProftpdConfProc(hiveValues, pacValuesList),
-		        createHttpdVirtualProc(pac.getName(), pacValuesList)));
+		        createHttpdVirtualProc(pac.getName(), pacValuesList),
+		        createAccountingRulesProc()));
 		waitingProcessor.appendProcessor(pac.getHiveName(), createDelUserProc(pac.getName()), "remove packet");
 		return waitingProcessor;
 	}
@@ -155,11 +158,13 @@
 		String username = unixUser.getName();
 		return new ShellProcessor("chmod 711 " + homedir + " && " +
 				"su -l " + username + " -s \"/bin/bash\" -c \"mkdir -p " +
+				homedir + "/.bak " +
 				homedir + "/doms " + 
 				homedir + "/etc " +
 				homedir + "/users " + 
 				homedir + "/var " + 
 				"\" && " +
+				"chmod 0700 " + homedir + "/.bak && " +
 				"chown httpd " + homedir + "/doms && " +
 				"chmod 1550 " + homedir + "/doms && " +
 				"chmod 2700 " + homedir + "/etc && " +
@@ -167,16 +172,6 @@
 				"chmod 2755 " + homedir + "/users"
 				);
 	}
-
-//	private Processor createSendEMailProc(String pacName,
-//			String customerEMail, Map<String, String> emailVars) throws ProcessorException {
-//		return new MailerProcessor(
-//						customerEMail, 
-//						"Zugangsdaten des neue Hostsharing Pakets " + pacName,
-//						"/de/hsadmin/mods/pac/email_new_pac_account.jtpl",
-//						emailVars
-//			);
-//	}
 
 	private Processor createIfUp(String pacName) {
 		return new ShellProcessor("ifup eth0:" + pacName);
@@ -223,14 +218,5 @@
 		}
 		return pacValuesList;
 	}
-
-//	private Map<String, String> fillEMailValues(String pacName,
-//			String customerEMail, String password) {
-//		Map<String, String> emailVars = new HashMap<String, String>();
-//		emailVars.put("PAC", pacName);
-//		emailVars.put("PASSWORD", password);
-//		emailVars.put("CUST_EMAIL", customerEMail);
-//		return emailVars;
-//	}
 
 }

--
Gitblit v1.9.0-SNAPSHOT