From 48c8d2777374b99ff2b55ac377980033d9c9c91a Mon Sep 17 00:00:00 2001 From: Michael Hierweck Date: Fri, 21 Sep 2012 14:58:36 +0200 Subject: [PATCH] Fixed migration code: pac domain to subdomain --- .../mods/dom/DomainProcessorFactory.java | 29 ++++++++++++++----- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java index dc7652f..4e4e983 100644 --- a/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java +++ b/hsarback/src/de/hsadmin/mods/dom/DomainProcessorFactory.java @@ -370,17 +370,32 @@ public class DomainProcessorFactory implements EntityProcessorFactory { String domDir = pacDir + "/doms/" + pac.getName() + ".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( - new ShellProcessor("rm -rf " + domDir + "/subs " + domDir + "/htdocs/.htaccess " - + domDir + "/subs-ssl " + domDir + "/htdocs-ssl/.htaccess ")); + CompoundProcessor processor = new CompoundProcessor(); + for (int idx = 0; idx < targetDirs.length; idx++) { + processor.appendProcessor( + 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] + "/ " + - " && ( rmdir " + pacDir + "/" + sourceDirs[idx] + " || rm " + pacDir + "/" + sourceDirs[idx] + " ) " + + " && mv " + pacDir + "/" + sourceDirs[idx] + domDir + "/" + targetDirs[idx] + " || echo 'directory " + pacDir + "/" + sourceDirs[idx] + " not found'")); - } - return processor; + } + processor.appendProcessor( + new ShellProcessor("test -L " + domDir + "/htdocs" + + " && `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")); + processor.appendProcessor( + new ShellProcessor("test -L " + domDir + "/htdocs-ssl" + + " && `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")); + return processor; } private String selectVHostTemplate(Domain dom) {