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" global="jms/hsadminSystem-h52"
type="javax.jms.Queue"/> 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 <ResourceLink
name="jms/hsadminSystem-h55" name="jms/hsadminSystem-h55"
global="jms/hsadminSystem-h55" global="jms/hsadminSystem-h55"
@ -85,6 +95,21 @@
global="jms/hsadminSystem-h58" global="jms/hsadminSystem-h58"
type="javax.jms.Queue"/> 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 <ResourceLink
name="jms/hsadminSystem-mail1" name="jms/hsadminSystem-mail1"
global="jms/hsadminSystem-mail1" global="jms/hsadminSystem-mail1"

View File

@ -229,6 +229,18 @@
<res-auth>Container</res-auth> <res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope> <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref> </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> <resource-ref>
<res-ref-name>jms/hsadminSystem-h55</res-ref-name> <res-ref-name>jms/hsadminSystem-h55</res-ref-name>
<res-type>javax.jms.Queue</res-type> <res-type>javax.jms.Queue</res-type>
@ -253,6 +265,24 @@
<res-auth>Container</res-auth> <res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope> <res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref> </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> <resource-ref>
<res-ref-name>jms/hsadminSystem-dns1</res-ref-name> <res-ref-name>jms/hsadminSystem-dns1</res-ref-name>
<res-type>javax.jms.Queue</res-type> <res-type>javax.jms.Queue</res-type>

View File

@ -39,7 +39,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
Domain dom = (Domain) entity; Domain dom = (Domain) entity;
UnixUser domUser = dom.getUser(); UnixUser domUser = dom.getUser();
Pac pac = domUser.getPac(); 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"); mainProcessor.appendProcessor(hiveName, createHiveEMailSetupProcessor(em, dom), "Setup EMail");
Config config = Config.getInstance(); Config config = Config.getInstance();
for (String queueName : config.getProperty("queues.dns").split(",")) { for (String queueName : config.getProperty("queues.dns").split(",")) {
@ -82,7 +82,19 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
return mainProcessor; 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>(); Map<String, Object> templateVars = new HashMap<String, Object>();
templateVars.put("sio", Long.toString(System.currentTimeMillis()/1000L)); templateVars.put("sio", Long.toString(System.currentTimeMillis()/1000L));
String domName = dom.getName(); 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); new VelocityProcessor("/de/hsadmin/mods/dom/zonefile.vm", templateVars, dom, zonefileTargetPath, false);
Processor zonefileACLProcessor = Processor zonefileACLProcessor =
new ShellProcessor("chown root:bind " + zonefileTargetPath + " && chmod 644 " + zonefileTargetPath); new ShellProcessor("chown root:bind " + zonefileTargetPath + " && chmod 644 " + zonefileTargetPath);
// TODO Use templates and regenerate the file. Query query = em.createQuery("SELECT d FROM Domains d WHERE d.user.pac.hive.name = :hivename");
Processor prizonesFileProcessor = query.setParameter("hivename", dom.getUser().getHiveName());
new ShellProcessor("echo 'zone \"" + domName + "\" { type master; file \"pri." + domName + "\"; };' >>/etc/bind/named.pri-zones" + templateVars = new HashMap<String, Object>();
" && sort /etc/bind/named.pri-zones | uniq >/etc/bind/named.pri-zones.tmp" + templateVars.put("domains", query.getResultList());
" && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones"); Processor prizonesFileProcessor = new CompoundProcessor(
Processor dnsReloadProcessor = new ShellProcessor("invoke-rc.d bind9 reload"); 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 = Processor dnsSetupProcessor =
new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor, dnsReloadProcessor); new CompoundProcessor(zonefileTemplateProcessor, zonefileACLProcessor, prizonesFileProcessor);
return dnsSetupProcessor; return dnsSetupProcessor;
} }
@ -124,18 +140,6 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
return emailAdrProcessor; 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 { private Processor createMailinSetupProcessor(EntityManager em, Domain dom, Pac pac) throws ProcessorException {
String inetAddr = pac.getCurINetAddr().getInetAddr(); String inetAddr = pac.getCurINetAddr().getInetAddr();
CompoundProcessor cp = new CompoundProcessor( 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} !^/cgi-bin/
RewriteCond %{REQUEST_URI} !^/fastcgi-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 RewriteCond /home/doms/${dom.name}/subs/#[[${tolower:%1} ]]# -d
RewriteRule ^(.*) /home/doms/${dom.name}/subs/#[[${tolower:%1}$1 ]]# [last] RewriteRule ^(.*) /home/doms/${dom.name}/subs/#[[${tolower:%1}$1 ]]# [last]

View File

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