clean code, templates dynamic and static web
This commit is contained in:
parent
3146e8d399
commit
b690312f6c
@ -19,15 +19,12 @@ import de.hsadmin.core.qserv.TemplateProcessor;
|
|||||||
import de.hsadmin.core.qserv.WaitingTasksProcessor;
|
import de.hsadmin.core.qserv.WaitingTasksProcessor;
|
||||||
import de.hsadmin.mods.email.EMailAddress;
|
import de.hsadmin.mods.email.EMailAddress;
|
||||||
import de.hsadmin.mods.email.EMailAddressProcessorFactory;
|
import de.hsadmin.mods.email.EMailAddressProcessorFactory;
|
||||||
|
import de.hsadmin.mods.pac.INetAddress;
|
||||||
import de.hsadmin.mods.pac.Pac;
|
import de.hsadmin.mods.pac.Pac;
|
||||||
import de.hsadmin.mods.user.UnixUser;
|
import de.hsadmin.mods.user.UnixUser;
|
||||||
|
|
||||||
public class DomainProcessorFactory implements EntityProcessorFactory {
|
public class DomainProcessorFactory implements EntityProcessorFactory {
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a Processor which creates a domain
|
|
||||||
* @throws ProcessorException
|
|
||||||
*/
|
|
||||||
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) throws ProcessorException {
|
public <T extends AbstractEntity> Processor createCreateProcessor(EntityManager em, T entity) throws ProcessorException {
|
||||||
String hiveName = entity.getHiveName();
|
String hiveName = entity.getHiveName();
|
||||||
Domain dom = (Domain) entity;
|
Domain dom = (Domain) entity;
|
||||||
@ -35,7 +32,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
Pac pac = domUser.getPac();
|
Pac pac = domUser.getPac();
|
||||||
String pacName = pac.getName();
|
String pacName = pac.getName();
|
||||||
String domName = dom.getName();
|
String domName = dom.getName();
|
||||||
String zonefileTargetPath = "/etc/bind/pri." + domName;
|
|
||||||
Map<String, String> templateVars = new HashMap<String, String>();
|
Map<String, String> templateVars = new HashMap<String, String>();
|
||||||
templateVars.put("SIO", Long.toString(System.currentTimeMillis()/1000L));
|
templateVars.put("SIO", Long.toString(System.currentTimeMillis()/1000L));
|
||||||
templateVars.put("PAC", pacName);
|
templateVars.put("PAC", pacName);
|
||||||
@ -43,7 +39,59 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
templateVars.put("DOM_HOSTNAME", domName);
|
templateVars.put("DOM_HOSTNAME", domName);
|
||||||
templateVars.put("DOM_USERNAME", domUser.getName());
|
templateVars.put("DOM_USERNAME", domUser.getName());
|
||||||
templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net");
|
templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net");
|
||||||
templateVars.put("DOM_IPNUMBER", pac.getCurINetAddr().getInetAddr());
|
templateVars.put("DOM_IPNUMBER", getCurrentIPAddress(pac));
|
||||||
|
templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac));
|
||||||
|
WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(createHiveDNSSetupProcessor(domName, templateVars));
|
||||||
|
mainProcessor.appendProcessor(hiveName, createHiveEMailSetupProcessor(em, domName), "Setup EMail");
|
||||||
|
String hiveInetAddr = pac.getHive().getInetAddr().getInetAddr();
|
||||||
|
for (String queueName : new String[] { "dns1", "dns2", "dns3" }) {
|
||||||
|
mainProcessor.appendProcessor(queueName, createDNSServerSetupProcessor(domName, hiveInetAddr), queueName + ".hostsharing.net");
|
||||||
|
}
|
||||||
|
for (String queueName : new String[] { "mail1", "mail2", "mail3" }) {
|
||||||
|
mainProcessor.appendProcessor(queueName, createMailinSetupProcessor(domName, pac), queueName + ".hostsharing.net");
|
||||||
|
}
|
||||||
|
mainProcessor.appendProcessor("backupmx", createBackupMXSetupProcessor(domName), "backupmx.hostsharing.net");
|
||||||
|
templateVars = new HashMap<String, String>();
|
||||||
|
templateVars.put("PAC", pacName);
|
||||||
|
templateVars.put("HIVE", pac.getHiveName());
|
||||||
|
templateVars.put("DOM_HOSTNAME", domName);
|
||||||
|
templateVars.put("DOM_USERNAME", domUser.getName());
|
||||||
|
templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net");
|
||||||
|
templateVars.put("DOM_IPNUMBER", getCurrentIPAddress(pac));
|
||||||
|
templateVars.put("DOM_IPNUMBEREX", getOldIPAddress(pac));
|
||||||
|
templateVars.put("DOMAIN", domName);
|
||||||
|
templateVars.put("USER_NAME", domUser.getComment());
|
||||||
|
mainProcessor.appendProcessor(hiveName, createApacheVHostSetupProcessor(dom, templateVars), "Setup Apache VHost");
|
||||||
|
return mainProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) throws ProcessorException {
|
||||||
|
throw new ProcessorException("domain.update not implemented");
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
|
||||||
|
Domain dom = (Domain) entity;
|
||||||
|
String domName = dom.getName();
|
||||||
|
WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(
|
||||||
|
new CompoundProcessor(
|
||||||
|
createHiveEMailRemoveProcessor(domName),
|
||||||
|
createHiveDNSRemoveProcessor(domName)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
for (String queueName : new String[] { "dns1", "dns2", "dns3" }) {
|
||||||
|
mainProcessor.appendProcessor(queueName, createDNSServerRemoveProcessor(domName), queueName + ".hostsharing.net");
|
||||||
|
}
|
||||||
|
for (String queueName : new String[] { "mail1", "mail2", "mail3" }) {
|
||||||
|
mainProcessor.appendProcessor(queueName, createMailinDeleteProcessor(domName), queueName + ".hostsharing.net");
|
||||||
|
}
|
||||||
|
mainProcessor.appendProcessor(dom.getHiveName(), createApacheVHostDeleteProcessor(dom), "remove apache vhost");
|
||||||
|
mainProcessor.appendProcessor("backupmx", createBackupMXDeleteProcessor(domName), "backupmx.hostsharing.net");
|
||||||
|
return mainProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Processor createHiveDNSSetupProcessor(String domName, Map<String, String> templateVars)
|
||||||
|
throws ProcessorException {
|
||||||
|
String zonefileTargetPath = "/etc/bind/pri." + domName;
|
||||||
Processor zonefileTemplateProcessor =
|
Processor zonefileTemplateProcessor =
|
||||||
new TemplateProcessor("/de/hsadmin/mods/dom/zonefile.jtpl", templateVars, zonefileTargetPath, false);
|
new TemplateProcessor("/de/hsadmin/mods/dom/zonefile.jtpl", templateVars, zonefileTargetPath, false);
|
||||||
Processor zonefileACLProcessor =
|
Processor zonefileACLProcessor =
|
||||||
@ -52,36 +100,60 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
new ShellProcessor("echo 'zone \"" + domName + "\" { type master; file \"pri." + domName + "\"; };' >>/etc/bind/named.pri-zones" +
|
new ShellProcessor("echo 'zone \"" + domName + "\" { type master; file \"pri." + domName + "\"; };' >>/etc/bind/named.pri-zones" +
|
||||||
" && sort /etc/bind/named.pri-zones | uniq >/etc/bind/named.pri-zones.tmp" +
|
" && sort /etc/bind/named.pri-zones | uniq >/etc/bind/named.pri-zones.tmp" +
|
||||||
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones");
|
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones");
|
||||||
String hiveInetAddr = pac.getHive().getInetAddr().getInetAddr();
|
|
||||||
Processor dnsReloadProcessor = new ShellProcessor("invoke-rc.d bind9 reload");
|
Processor dnsReloadProcessor = new ShellProcessor("invoke-rc.d bind9 reload");
|
||||||
EMailAddressProcessorFactory eMailAddressProcessorFactory = new EMailAddressProcessorFactory();
|
|
||||||
Processor dnsSetupProcessor =
|
Processor dnsSetupProcessor =
|
||||||
new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor, dnsReloadProcessor);
|
new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor, dnsReloadProcessor);
|
||||||
WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(dnsSetupProcessor);
|
return dnsSetupProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ShellProcessor createHiveDNSRemoveProcessor(String domName) {
|
||||||
|
return new ShellProcessor("grep -v '\"pri." + domName + "\"' /etc/bind/named.pri-zones > /etc/bind/named.pri-zones.tmp" +
|
||||||
|
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" +
|
||||||
|
" && rm /etc/bind/pri." + domName +
|
||||||
|
" && invoke-rc.d bind9 reload");
|
||||||
|
}
|
||||||
|
|
||||||
|
private CompoundProcessor createHiveEMailSetupProcessor(EntityManager em, String domName) {
|
||||||
|
EMailAddressProcessorFactory eMailAddressProcessorFactory = new EMailAddressProcessorFactory();
|
||||||
CompoundProcessor emailAdrProcessor = new CompoundProcessor();
|
CompoundProcessor emailAdrProcessor = new CompoundProcessor();
|
||||||
Query query = em.createQuery("SELECT adr FROM " + EMailAddress.class.getAnnotation(javax.persistence.Entity.class).name()
|
Query query = em.createQuery(
|
||||||
+ " adr WHERE adr.domain.name='" + domName + "'");
|
"SELECT adr FROM " +
|
||||||
|
EMailAddress.class.getAnnotation(javax.persistence.Entity.class).name() + " adr " +
|
||||||
|
"WHERE adr.domain.name='" + domName + "'");
|
||||||
List<?> resultList = query.getResultList();
|
List<?> resultList = query.getResultList();
|
||||||
for (Object obj : resultList) {
|
for (Object obj : resultList) {
|
||||||
EMailAddress eMailAddress = (EMailAddress) obj;
|
EMailAddress eMailAddress = (EMailAddress) obj;
|
||||||
emailAdrProcessor.appendProcessor(eMailAddressProcessorFactory.createCreateProcessor(em, eMailAddress));
|
emailAdrProcessor.appendProcessor(eMailAddressProcessorFactory.createCreateProcessor(em, eMailAddress));
|
||||||
}
|
}
|
||||||
mainProcessor.appendProcessor(hiveName, emailAdrProcessor, "Setup EMail");
|
return emailAdrProcessor;
|
||||||
Processor seczonesFileProcessor = null;
|
}
|
||||||
String[] dnsServerQueues = { "dns1", "dns2", "dns3" };
|
|
||||||
for (String queueName : dnsServerQueues) {
|
private ShellProcessor createHiveEMailRemoveProcessor(String domName) {
|
||||||
|
return new ShellProcessor(
|
||||||
|
"for KEY in $(postmap -s /etc/postfix/virtual|grep '@" + domName + "\\s'|cut -f1); " +
|
||||||
|
"do postmap -d $KEY /etc/postfix/virtual; done");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Processor createDNSServerSetupProcessor(String domName,
|
||||||
|
String hiveInetAddr) {
|
||||||
|
Processor seczonesFileProcessor;
|
||||||
seczonesFileProcessor =
|
seczonesFileProcessor =
|
||||||
new ShellProcessor("echo 'zone \"" + domName + "\" { type slave; file \"sec." + domName + "\"; masters { " + hiveInetAddr + "; }; };' >>/etc/bind/named-hsh.conf" +
|
new ShellProcessor("echo 'zone \"" + domName + "\" { type slave; file \"sec." + domName + "\"; masters { " + hiveInetAddr + "; }; };' >>/etc/bind/named-hsh.conf" +
|
||||||
" && sort /etc/bind/named-hsh.conf | uniq >/etc/bind/named-hsh.conf.tmp" +
|
" && sort /etc/bind/named-hsh.conf | uniq >/etc/bind/named-hsh.conf.tmp" +
|
||||||
" && mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf" +
|
" && mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf" +
|
||||||
" && invoke-rc.d bind9 reload");
|
" && invoke-rc.d bind9 reload");
|
||||||
mainProcessor.appendProcessor(queueName, seczonesFileProcessor, queueName + ".hostsharing.net");
|
return seczonesFileProcessor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Processor relayDomainsProcessor = null;
|
private Processor createDNSServerRemoveProcessor(String domName) {
|
||||||
String[] mailServerQueues = { "mail1", "mail2", "mail3" };
|
return new ShellProcessor("grep -v '\"sec." + domName + "\"' /etc/bind/named-hsh.conf >/etc/bind/named-hsh.conf.tmp" +
|
||||||
for (String queueName : mailServerQueues) {
|
" && mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf" +
|
||||||
relayDomainsProcessor = new CompoundProcessor(
|
" && rm /var/cache/bind/sec." + domName +
|
||||||
|
" && invoke-rc.d bind9 reload");
|
||||||
|
}
|
||||||
|
|
||||||
|
private Processor createMailinSetupProcessor(String domName, Pac pac) {
|
||||||
|
return new CompoundProcessor(
|
||||||
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
|
new ShellProcessor("postmap -r -i /etc/postfix-mailin/relaydomains",
|
||||||
domName + " anything\n" +
|
domName + " anything\n" +
|
||||||
"." + domName + " anything\n"),
|
"." + domName + " anything\n"),
|
||||||
@ -89,17 +161,37 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n" +
|
domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n" +
|
||||||
"." + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n")
|
"." + domName + " smtp:[" + pac.getName() + ".hostsharing.net]\n")
|
||||||
);
|
);
|
||||||
mainProcessor.appendProcessor(queueName, relayDomainsProcessor, queueName + ".hostsharing.net");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Processor backupMXSMTPTransportsProcessor =
|
private Processor createMailinDeleteProcessor(String domName) {
|
||||||
new ShellProcessor("echo " + domName + " >> /etc/postfix/relaydomains" +
|
Processor mailQueueProcessor = new ShellProcessor("postmap -d '" + domName + "' /etc/postfix-mailin/relaydomains && " +
|
||||||
|
"postmap -d '" + domName + "' /etc/postfix-mailin/transport && " +
|
||||||
|
"postmap -d '." + domName + "' /etc/postfix-mailin/relaydomains && " +
|
||||||
|
"postmap -d '." + domName + "' /etc/postfix-mailin/transport");
|
||||||
|
return mailQueueProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Processor createBackupMXSetupProcessor(String domName) {
|
||||||
|
return new ShellProcessor("echo " + domName + " >> /etc/postfix/relaydomains" +
|
||||||
" && invoke-rc.d postfix reload");
|
" && invoke-rc.d postfix reload");
|
||||||
mainProcessor.appendProcessor("backupmx", backupMXSMTPTransportsProcessor, "backupmx.hostsharing.net");
|
}
|
||||||
|
|
||||||
|
private Processor createBackupMXDeleteProcessor(String domName) {
|
||||||
|
Processor backupMXSMTPRelayDelProcessor =
|
||||||
|
new ShellProcessor("grep -v '^" + domName + "$' /etc/postfix/relaydomains > /etc/postfix/relaydomains.tmp" +
|
||||||
|
" && mv /etc/postfix/relaydomains.tmp /etc/postfix/relaydomains" +
|
||||||
|
" && invoke-rc.d postfix reload");
|
||||||
|
return backupMXSMTPRelayDelProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
private CompoundProcessor createDomainDirectoriesProcessor(Domain dom, Map<String, String> templateVars) throws ProcessorException {
|
||||||
|
UnixUser domUser = dom.getUser();
|
||||||
|
String domName = dom.getName();
|
||||||
|
String pacName = domUser.getPac().getName();
|
||||||
String domsDir = domUser.getHomedir() + "/doms";
|
String domsDir = domUser.getHomedir() + "/doms";
|
||||||
|
String userName = domUser.getName();
|
||||||
String domainDir = domsDir + "/" + dom.getName();
|
String domainDir = domsDir + "/" + dom.getName();
|
||||||
String[] subDirs = new String[] { "htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "cgi", "fastcgi", "cgi-ssl", "fastcgi-ssl", "etc", "var" };
|
String[] subDirs = new String[] { "htdocs", "htdocs-ssl", "subs", "subs/www", "subs-ssl", "subs-ssl/www", "cgi", "fastcgi", "cgi-ssl", "fastcgi-ssl", "etc", "var" };
|
||||||
String userName = domUser.getName();
|
|
||||||
Processor mkDomainDirProzessor =
|
Processor mkDomainDirProzessor =
|
||||||
new ShellProcessor(
|
new ShellProcessor(
|
||||||
"mkdir --mode=1550 --parents " + domsDir + " && " +
|
"mkdir --mode=1550 --parents " + domsDir + " && " +
|
||||||
@ -114,18 +206,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
"chown " + userName + ":" + pacName + " " + domainDir + "/" + subDir
|
"chown " + userName + ":" + pacName + " " + domainDir + "/" + subDir
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
templateVars = new HashMap<String, String>();
|
|
||||||
templateVars.put("PAC", pacName);
|
|
||||||
templateVars.put("HIVE", pac.getHiveName());
|
|
||||||
templateVars.put("DOM_HOSTNAME", domName);
|
|
||||||
templateVars.put("DOM_USERNAME", domUser.getName());
|
|
||||||
templateVars.put("PAC_HOSTNAME", pacName + ".hostsharing.net");
|
|
||||||
templateVars.put("DOM_IPNUMBER", pac.getCurINetAddr().getInetAddr());
|
|
||||||
templateVars.put("DOMAIN", domName);
|
|
||||||
templateVars.put("USER_NAME", domUser.getComment());
|
|
||||||
domDirsProcessor.appendProcessor(
|
|
||||||
new CreateFileProcessor("/de/hsadmin/mods/dom/httpd.conf.jtpl", templateVars, "/etc/apache2/sites-generated/" + domName, "root", "root", "644")
|
|
||||||
);
|
|
||||||
templateVars.put("PROTOCOL", "http");
|
templateVars.put("PROTOCOL", "http");
|
||||||
domDirsProcessor.appendProcessor(
|
domDirsProcessor.appendProcessor(
|
||||||
new CreateFileProcessor("/de/hsadmin/mods/dom/htaccess.jtpl", templateVars, domainDir + "/htdocs/.htaccess", userName, pacName, "644")
|
new CreateFileProcessor("/de/hsadmin/mods/dom/htaccess.jtpl", templateVars, domainDir + "/htdocs/.htaccess", userName, pacName, "644")
|
||||||
@ -157,70 +237,55 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
|
|||||||
"chown --no-dereference " + userName + ":httpd /home/doms/" + domName
|
"chown --no-dereference " + userName + ":httpd /home/doms/" + domName
|
||||||
+ " && " + "chown " + userName + ":httpd /home/doms/" + domName + "/")
|
+ " && " + "chown " + userName + ":httpd /home/doms/" + domName + "/")
|
||||||
);
|
);
|
||||||
mainProcessor.appendProcessor(hiveName, domDirsProcessor, "Setup doms/" + domName + "-Directory");
|
return domDirsProcessor;
|
||||||
|
|
||||||
Processor domSetupProcessor =
|
|
||||||
new ShellProcessor("ln -s /etc/apache2/sites-generated/" + domName + " /etc/apache2/sites-enabled/010-" + domName + " && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
|
||||||
mainProcessor.appendProcessor(hiveName, domSetupProcessor, "Setup Apache VHost");
|
|
||||||
return mainProcessor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
private Processor createApacheVHostSetupProcessor(Domain dom, Map<String, String> templateVars)
|
||||||
* @return a Processor which updates a domain
|
throws ProcessorException {
|
||||||
*/
|
|
||||||
public <T extends AbstractEntity> Processor createUpdateProcessor(EntityManager em, T entity) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return a Processor which deletes a domain
|
|
||||||
*/
|
|
||||||
public <T extends AbstractEntity> Processor createDeleteProcessor(EntityManager em, T entity) {
|
|
||||||
Domain dom = (Domain) entity;
|
|
||||||
String domName = dom.getName();
|
String domName = dom.getName();
|
||||||
ShellProcessor emailAddressRemoveProcessor = new ShellProcessor("for KEY in $(postmap -s /etc/postfix/virtual|grep '@" + domName + "\\s'|cut -f1); do postmap -d $KEY /etc/postfix/virtual; done");
|
Processor domSetupProcessor = new CompoundProcessor(
|
||||||
ShellProcessor dnsRemoveRemoveProcessor =
|
createDomainDirectoriesProcessor(dom, templateVars),
|
||||||
new ShellProcessor("grep -v '\"pri." + domName + "\"' /etc/bind/named.pri-zones > /etc/bind/named.pri-zones.tmp" +
|
new CreateFileProcessor(selectVHostTemplate(dom), templateVars, "/etc/apache2/sites-generated/" + domName, "root", "root", "644"),
|
||||||
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" +
|
new ShellProcessor("ln -sf /etc/apache2/sites-generated/" + domName + " /etc/apache2/sites-enabled/010-" + domName + " && invoke-rc.d apache2 reload >/dev/null 2>&1")
|
||||||
" && rm /etc/bind/pri." + domName +
|
);
|
||||||
" && invoke-rc.d bind9 reload");
|
return domSetupProcessor;
|
||||||
WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(new CompoundProcessor(emailAddressRemoveProcessor, dnsRemoveRemoveProcessor));
|
|
||||||
|
|
||||||
Processor seczonesFileProcessor = null;
|
|
||||||
String[] dnsQueues = { "dns1", "dns2", "dns3" };
|
|
||||||
for (String queueName : dnsQueues) {
|
|
||||||
seczonesFileProcessor =
|
|
||||||
new ShellProcessor("grep -v '\"sec." + domName + "\"' /etc/bind/named-hsh.conf >/etc/bind/named-hsh.conf.tmp" +
|
|
||||||
" && mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf" +
|
|
||||||
" && rm /var/cache/bind/sec." + domName +
|
|
||||||
" && invoke-rc.d bind9 reload");
|
|
||||||
mainProcessor.appendProcessor(queueName, seczonesFileProcessor, queueName + ".hostsharing.net");
|
|
||||||
}
|
|
||||||
|
|
||||||
Processor mailQueueProcessor = null;
|
|
||||||
String[] mailServerQueues = { "mail1", "mail2", "mail3" };
|
|
||||||
for (String queueName : mailServerQueues) {
|
|
||||||
mailQueueProcessor = new ShellProcessor("postmap -d '" + domName + "' /etc/postfix-mailin/relaydomains && " +
|
|
||||||
"postmap -d '" + domName + "' /etc/postfix-mailin/transport && " +
|
|
||||||
"postmap -d '." + domName + "' /etc/postfix-mailin/relaydomains && " +
|
|
||||||
"postmap -d '." + domName + "' /etc/postfix-mailin/transport");
|
|
||||||
mainProcessor.appendProcessor(queueName, mailQueueProcessor, queueName + ".hostsharing.net");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Processor createApacheVHostDeleteProcessor(Domain dom) {
|
||||||
|
String domName = dom.getName();
|
||||||
Processor vhostDelProcessor =
|
Processor vhostDelProcessor =
|
||||||
new ShellProcessor("rm /home/doms/" + domName +
|
new ShellProcessor("rm /home/doms/" + domName +
|
||||||
" && rm -rf " + dom.getUser().getHomedir() + "/doms/" + domName +
|
" && rm -rf " + dom.getUser().getHomedir() + "/doms/" + domName +
|
||||||
" && rm /etc/apache2/sites-generated/" + domName +
|
" && rm /etc/apache2/sites-generated/" + domName +
|
||||||
" && rm /etc/apache2/sites-*/`ls -1 /etc/apache2/sites-enabled/ | egrep \"^[01]+-" + domName + "$\"`" +
|
" && rm /etc/apache2/sites-*/`ls -1 /etc/apache2/sites-enabled/ | egrep \"^[01]+-" + domName + "$\"`" +
|
||||||
" && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
" && invoke-rc.d apache2 reload >/dev/null 2>&1");
|
||||||
mainProcessor.appendProcessor(dom.getHiveName(), vhostDelProcessor, "remove apache vhost");
|
return vhostDelProcessor;
|
||||||
|
}
|
||||||
|
|
||||||
Processor backupMXSMTPRelayDelProcessor =
|
private String selectVHostTemplate(Domain dom) {
|
||||||
new ShellProcessor("grep -v '^" + domName + "$' /etc/postfix/relaydomains > /etc/postfix/relaydomains.tmp" +
|
String domName = dom.getName();
|
||||||
" && mv /etc/postfix/relaydomains.tmp /etc/postfix/relaydomains" +
|
UnixUser user = dom.getUser();
|
||||||
" && invoke-rc.d postfix reload");
|
Pac pac = user.getPac();
|
||||||
mainProcessor.appendProcessor("backupmx", backupMXSMTPRelayDelProcessor, "backupmx.hostsharing.net");
|
if (domName.equals(pac.getName() + ".hostsharing.net")) {
|
||||||
return mainProcessor;
|
return "/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl";
|
||||||
|
}
|
||||||
|
if (pac.getBasepac().getName().startsWith("DW")) {
|
||||||
|
return "/de/hsadmin/mods/dom/httpd-vhost-dynamic.jtpl";
|
||||||
|
}
|
||||||
|
return "/de/hsadmin/mods/dom/httpd-vhost-static.jtpl";
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getCurrentIPAddress(Pac pac) {
|
||||||
|
return pac.getCurINetAddr().getInetAddr();
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getOldIPAddress(Pac pac) {
|
||||||
|
INetAddress oldINetAddr = pac.getOldINetAddr();
|
||||||
|
if (oldINetAddr != null) {
|
||||||
|
return oldINetAddr.getInetAddr();
|
||||||
|
} else {
|
||||||
|
return getCurrentIPAddress(pac);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
NameVirtualHost {DOM_IPNUMBER}:80
|
NameVirtualHost {DOM_IPNUMBER}:80
|
||||||
NameVirtualHost {DOM_IPNUMBER}:80
|
NameVirtualHost {DOM_IPNUMBEREX}:80
|
||||||
|
|
||||||
<VirtualHost {DOM_IPNUMBER}:80 {DOM_IPNUMBER}:80>
|
<VirtualHost {DOM_IPNUMBER}:80 {DOM_IPNUMBEREX}:80>
|
||||||
|
|
||||||
ServerName {DOM_HOSTNAME}
|
ServerName {DOM_HOSTNAME}
|
||||||
ServerAlias *.{DOM_HOSTNAME}
|
ServerAlias *.{DOM_HOSTNAME}
|
||||||
@ -49,9 +49,9 @@ NameVirtualHost {DOM_IPNUMBER}:80
|
|||||||
</VirtualHost>
|
</VirtualHost>
|
||||||
|
|
||||||
NameVirtualHost {DOM_IPNUMBER}:443
|
NameVirtualHost {DOM_IPNUMBER}:443
|
||||||
NameVirtualHost {DOM_IPNUMBER}:443
|
NameVirtualHost {DOM_IPNUMBEREX}:443
|
||||||
|
|
||||||
<VirtualHost {DOM_IPNUMBER}:443 {DOM_IPNUMBER}:443>
|
<VirtualHost {DOM_IPNUMBER}:443 {DOM_IPNUMBEREX}:443>
|
||||||
|
|
||||||
ServerName {DOM_HOSTNAME}
|
ServerName {DOM_HOSTNAME}
|
||||||
ServerAlias *.{DOM_HOSTNAME}
|
ServerAlias *.{DOM_HOSTNAME}
|
85
hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl
Normal file
85
hsarback/src/de/hsadmin/mods/dom/httpd-vhost-static.jtpl
Normal file
@ -0,0 +1,85 @@
|
|||||||
|
NameVirtualHost {DOM_IPNUMBER}:80
|
||||||
|
NameVirtualHost {DOM_IPNUMBEREX}:80
|
||||||
|
|
||||||
|
<VirtualHost {DOM_IPNUMBER}:80 {DOM_IPNUMBEREX}:80>
|
||||||
|
|
||||||
|
ServerName {DOM_HOSTNAME}
|
||||||
|
ServerAlias *.{DOM_HOSTNAME}
|
||||||
|
ServerAdmin {DOM_USERNAME}@{HIVE}.hostsharing.net
|
||||||
|
|
||||||
|
SuexecUserGroup {DOM_USERNAME} {PAC}
|
||||||
|
|
||||||
|
DocumentRoot /home/doms/{DOM_HOSTNAME}/htdocs
|
||||||
|
|
||||||
|
<Directory />
|
||||||
|
Options -ExecCGI +IncludesNOEXEC +Indexes +MultiViews +SymLinksIfOwnerMatch
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Directory /home/doms/{DOM_HOSTNAME}/>
|
||||||
|
AllowOverride AuthConfig FileInfo Indexes Limit
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Location /cgi-bin/>
|
||||||
|
Redirect 501
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
<Location /fastcgi-bin/>
|
||||||
|
Redirect 501
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteOptions Inherit
|
||||||
|
#RewriteLog /home/doms/{DOM_HOSTNAME}/var/rewrite.log
|
||||||
|
#RewriteLogLevel 9
|
||||||
|
|
||||||
|
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]
|
||||||
|
|
||||||
|
</VirtualHost>
|
||||||
|
|
||||||
|
NameVirtualHost {DOM_IPNUMBER}:443
|
||||||
|
NameVirtualHost {DOM_IPNUMBEREX}:443
|
||||||
|
|
||||||
|
<VirtualHost {DOM_IPNUMBER}:443 {DOM_IPNUMBEREX}:443>
|
||||||
|
|
||||||
|
ServerName {DOM_HOSTNAME}
|
||||||
|
ServerAlias *.{DOM_HOSTNAME}
|
||||||
|
ServerAdmin {DOM_USERNAME}@{HIVE}.hostsharing.net
|
||||||
|
|
||||||
|
SuexecUserGroup {DOM_USERNAME} {PAC}
|
||||||
|
|
||||||
|
SSLEngine On
|
||||||
|
SSLCertificateFile /etc/apache2/pems/default.pem
|
||||||
|
SSLCertificateChainFile /etc/apache2/pems/default.chain.pem
|
||||||
|
|
||||||
|
DocumentRoot /home/doms/{DOM_HOSTNAME}/htdocs-ssl
|
||||||
|
|
||||||
|
<Directory />
|
||||||
|
SSLRequireSSL On
|
||||||
|
Options -ExecCGI +IncludesNOEXEC +Indexes +MultiViews +SymLinksIfOwnerMatch
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Directory /home/doms/{DOM_HOSTNAME}/>
|
||||||
|
AllowOverride AuthConfig FileInfo Indexes Limit
|
||||||
|
</Directory>
|
||||||
|
|
||||||
|
<Location /cgi-bin/>
|
||||||
|
Redirect 501
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
<Location /fastcgi-bin/>
|
||||||
|
Redirect 501
|
||||||
|
</Location>
|
||||||
|
|
||||||
|
RewriteEngine On
|
||||||
|
RewriteOptions Inherit
|
||||||
|
#RewriteLog /home/doms/{DOM_HOSTNAME}/var/rewrite.log
|
||||||
|
#RewriteLogLevel 9
|
||||||
|
|
||||||
|
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]
|
||||||
|
|
||||||
|
</VirtualHost>
|
||||||
|
|
@ -106,8 +106,6 @@ public class Pac extends AbstractEntity implements Serializable {
|
|||||||
comp.getBaseComponent(), this, comp.getDefaultQuantity(),
|
comp.getBaseComponent(), this, comp.getDefaultQuantity(),
|
||||||
today, null);
|
today, null);
|
||||||
pacComponents.add(pacComp);
|
pacComponents.add(pacComp);
|
||||||
System.err.println("TRACE [Pac]: added pacComp " + pacComp + " to "
|
|
||||||
+ getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user