From fd516ce57ab9240daa1f979371528fb9ff74bd75 Mon Sep 17 00:00:00 2001
From: Peter Hormanns <peter.hormanns@jalin.de>
Date: Thu, 18 Oct 2012 16:21:44 +0200
Subject: [PATCH] fix pac-domain migration

---
 hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
index b09d7d3..de64e48 100644
--- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
+++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java
@@ -374,35 +374,36 @@
 
 	private Processor createMovePacDomainContent(EntityManager em, Domain dom) {
 		Pac pac = dom.getUser().getPac();
-		String pacDir = "/home/pacs/" + pac.getName();
-		String domDir = pacDir + "/doms/" + pac.getName() + ".hostsharing.net"; 
+		String pacName = pac.getName();
+		String pacDir = "/home/pacs/" + pacName;
+		String domDir = pacDir + "/doms/" + pacName + ".hostsharing.net"; 
 		String[] sourceDirs = new String[] { "web", "web-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ;
 		String[] targetDirs = new String[] { "htdocs", "htdocs-ssl", "cgi", "cgi-ssl", "fastcgi", "fastcgi-ssl" } ;
 		CompoundProcessor processor = new CompoundProcessor();
 		for (int idx = 0; idx < targetDirs.length; idx++) {
 			processor.appendProcessor(
-					new ShellProcessor("rm -rf " + domDir + targetDirs[idx]));
+					new ShellProcessor("rm -rf " + domDir + "/" + targetDirs[idx]));
 		}
 		for (int idx = 0; idx < sourceDirs.length; idx++) {
 			processor.appendProcessor(
 				new ShellProcessor("shopt -s dotglob && ls " + pacDir + "/" + sourceDirs[idx] + " >/dev/null 2>&1" +
-						" && mv " + pacDir + "/" + sourceDirs[idx] + domDir + "/" + targetDirs[idx] +
+						" && mv " + pacDir + "/" + sourceDirs[idx] + " " + domDir + "/" + targetDirs[idx] +
 						" || echo 'directory " + pacDir + "/" + sourceDirs[idx] + " not found'"));
 		}		
 		processor.appendProcessor(
 				new ShellProcessor("test -L " + domDir + "/htdocs" +
-						" && `stat -c '%N' " + domDir + "/htdocs |sed -e's/^.*`//' -e\"s/'$//\"` = web-ssl " +
+						" && `stat -c '%N' " + domDir + "/htdocs` |sed -e's/^.*`//' -e\"s/'$//\"` = web-ssl " +
 						" && cd " + domDir +
 						" && rm " + domDir + "/htdocs" +
 						" && ln -sf htdocs-ssl htdocs" +
-						" && chown -h " + pac + ":" + pac + " " + domDir + "/htdocs"));
+						" && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs"));
 		processor.appendProcessor(
 				new ShellProcessor("test -L " + domDir + "/htdocs-ssl" +
-						" && `stat -c '%N' " + domDir + "/htdocs-ssl |sed -e's/^.*`//' -e\"s/'$//\"` = web " +
+						" && `stat -c '%N' " + domDir + "/htdocs-ssl` |sed -e's/^.*`//' -e\"s/'$//\"` = web " +
 						" && cd " + domDir +
 						" && rm " + domDir + "/htdocs-ssl" +
 						" && ln -sf htdocs htdocs-ssl" +
-						" && chown -h " + pac + ":" + pac + " " + domDir + "/htdocs-ssl"));
+						" && chown -h " + pacName + ":" + pacName + " " + domDir + "/htdocs-ssl"));
 		return processor;		
 	}
 

--
Gitblit v1.9.1