Merge branch 'master' of ssh://hsh04-source@hsh04.hostsharing.net/home/doms/source.hostsharing.net/source/hsadmin.git

This commit is contained in:
Purodha 2013-04-02 16:56:29 +01:00
commit e762eb2145
8 changed files with 98 additions and 33 deletions

View File

@ -65,6 +65,16 @@
global="jms/hsadminSystem-h52"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-h53"
global="jms/hsadminSystem-h53"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-h54"
global="jms/hsadminSystem-h54"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-h55"
global="jms/hsadminSystem-h55"
@ -85,6 +95,21 @@
global="jms/hsadminSystem-h58"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-h59"
global="jms/hsadminSystem-h59"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-h60"
global="jms/hsadminSystem-h60"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-h61"
global="jms/hsadminSystem-h61"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-mail1"
global="jms/hsadminSystem-mail1"

View File

@ -229,6 +229,18 @@
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h53</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h54</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h55</res-ref-name>
<res-type>javax.jms.Queue</res-type>
@ -253,6 +265,24 @@
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h59</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h60</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h61</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-dns1</res-ref-name>
<res-type>javax.jms.Queue</res-type>

View File

@ -39,7 +39,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
Domain dom = (Domain) entity;
UnixUser domUser = dom.getUser();
Pac pac = domUser.getPac();
WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(createHiveDNSSetupProcessor(dom));
WaitingTasksProcessor mainProcessor = new WaitingTasksProcessor(createHiveDNSSetupProcessor(em, dom));
mainProcessor.appendProcessor(hiveName, createHiveEMailSetupProcessor(em, dom), "Setup EMail");
Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.dns").split(",")) {
@ -82,7 +82,19 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
return mainProcessor;
}
private Processor createHiveDNSSetupProcessor(Domain dom) throws ProcessorException {
private Processor createDNSServerConfigProcessor(EntityManager em) {
Query query = em.createQuery("SELECT d FROM Domains d");
HashMap<String, Object> templateVars = new HashMap<String, Object>();
templateVars.put("domains", query.getResultList());
return new CompoundProcessor(
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
templateVars, "/etc/bind/named-hsh.conf.tmp", true),
new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " +
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )")
);
}
private Processor createHiveDNSSetupProcessor(EntityManager em, Domain dom) throws ProcessorException {
Map<String, Object> templateVars = new HashMap<String, Object>();
templateVars.put("sio", Long.toString(System.currentTimeMillis()/1000L));
String domName = dom.getName();
@ -91,14 +103,18 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
new VelocityProcessor("/de/hsadmin/mods/dom/zonefile.vm", templateVars, dom, zonefileTargetPath, false);
Processor zonefileACLProcessor =
new ShellProcessor("chown root:bind " + zonefileTargetPath + " && chmod 644 " + zonefileTargetPath);
// TODO Use templates and regenerate the file.
Processor prizonesFileProcessor =
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" +
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones");
Processor dnsReloadProcessor = new ShellProcessor("invoke-rc.d bind9 reload");
Query query = em.createQuery("SELECT d FROM Domains d WHERE d.user.pac.hive.name = :hivename");
query.setParameter("hivename", dom.getUser().getHiveName());
templateVars = new HashMap<String, Object>();
templateVars.put("domains", query.getResultList());
Processor prizonesFileProcessor = new CompoundProcessor(
new VelocityProcessor("/de/hsadmin/mods/dom/named-pri-zones.vm",
templateVars, dom, "/etc/bind/named.pri-zones.tmp", true),
new ShellProcessor(" ( diff -q /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones && rm /etc/bind/named.pri-zones.tmp ) " +
"|| ( mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones && invoke-rc.d bind9 reload )")
);
Processor dnsSetupProcessor =
new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor, dnsReloadProcessor);
new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor);
return dnsSetupProcessor;
}
@ -124,18 +140,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
return emailAdrProcessor;
}
private Processor createDNSServerConfigProcessor(EntityManager em) {
Query query = em.createQuery("SELECT d FROM Domains d");
HashMap<String, Object> templateVars = new HashMap<String, Object>();
templateVars.put("domains", query.getResultList());
return new CompoundProcessor(
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
templateVars, "/etc/bind/named-hsh.conf.tmp", true),
new ShellProcessor(" ( diff -q /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && rm /etc/bind/named-hsh.conf.tmp ) " +
"|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && invoke-rc.d bind9 reload )")
);
}
private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException {
String inetAddr = pac.getCurINetAddr().getInetAddr();
CompoundProcessor cp = new CompoundProcessor(

View File

@ -1 +1 @@
Redirect permanent / ${protocol}://www.${domain.name}/
Redirect permanent / ${protocol}://www.${dom.name}/

View File

@ -51,7 +51,7 @@
RewriteCond %{REQUEST_URI} !^/cgi-bin/
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?\$ [novary]
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
RewriteCond /home/doms/${dom.name}/subs/#[[${tolower:%1} ]]# -d
RewriteRule ^(.*) /home/doms/${dom.name}/subs/#[[${tolower:%1}$1 ]]# [last]

View File

@ -4,5 +4,5 @@
//
#foreach( $domain in ${domains} )
zone "${domain.name}" { type slave; file "sec.${domain.name}"; masters { ${domain.user.pac.hive.inetaddr}; }; };
zone "${domain.name}" { type slave; file "sec.${domain.name}"; masters { ${domain.user.pac.hive.inetAddr.inetAddr}; }; };
#end

View File

@ -0,0 +1,8 @@
//
// This file is managed by HSAdmin.
// Do not edit manually. Changes will be overwritten.
//
#foreach( $domain in ${domains} )
zone "${domain.name}" { type master; file "pri.${domain.name}"; };
#end

View File

@ -29,12 +29,10 @@ function shadowdump(pac) {
+ "|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump;
runbash(cmd);
}
function mysqlpasswddump(pac) {
function mysqlaclsdump(pac) {
var dump = "/home/pacs/" + pac + "/.bak/mysql_passwd.gz";
var sql = "select concat('update user set Password=\\\'', Password, '\\\' where User=\\\'', User, '\\\';')"
+ " as update_passwd from user where user like '" + pac + "%';";
var cmd = "( ( echo \"" + sql + "\"|mysql mysql ) ; echo \"flush privileges;\" )"
+ "|sed '1d'|gzip --best|secat --user=" + pac + " --group=" + pac + " --umask=007 --output=" + dump;
var cmd = "mysqldump --no-create-db --skip-opt --no-create-info --replace --where=\"user like '" + pac + "%'\" mysql --tables user > " + dump
+ " && mysqldump --no-create-db --skip-opt --no-create-info --replace --where=\"db like '" + pac + "%'\" mysql --tables db tables_priv proc >>" + dump;
runbash(cmd);
}
function pgsqlpasswddump(pac) {
@ -129,7 +127,7 @@ if (pacs.length == 1 && hive != 'undef') {
file.write('target: [\n');
if (addresses[idx]['target']) {
for (jdx=0; jdx<addresses[idx]['target'].length; jdx++) {
file.write(' "' + addresses[idx]['target'][jdx] + '",\n');
file.write(' \'' + addresses[idx]['target'][jdx] + '\',\n');
}
}
file.write(' ]\n');
@ -207,7 +205,7 @@ if (pacs.length == 1 && hive != 'undef') {
}
file.close();
shadowdump(pacname);
mysqlpasswddump(pacname);
mysqlaclsdump(pacname);
pgsqlpasswddump(pacname);
} else {
print('run as pac-owner!\n');