Compare commits

...

43 Commits

Author SHA1 Message Date
Peter Hormanns
e8c256da9c Merge branch 'master' into TP-202311-vhost-bookworm 2024-04-17 16:38:41 +02:00
Timotheus Pokorra
79c653e910 Paths for Passenger Python, Ruby, Node and PHP should also support underscore characters 2024-04-16 22:13:57 +02:00
Peter Hormanns
69d9d87c9b available only on bookworm 2024-04-06 14:43:42 +02:00
Peter Hormanns
96c3396934 add Option PassengerPreloadBundler to apache vhosts 2024-03-25 18:52:56 +01:00
Peter Hormanns
e1db7a784f use systemctl instead of invoke-rc.d 2024-03-25 13:54:44 +01:00
Peter Hormanns
7a16ff9165 Option Includes replaces IncludesNoExec 2024-03-13 11:04:52 +01:00
Peter Hormanns
694b13bb55 avoid nullpointer in pillarservlet 2024-01-25 19:39:35 +01:00
Peter Hormanns
22a99e98a3 use hs-phpstub as phpstub 2024-01-25 18:01:43 +01:00
Peter Hormanns
b16ba63833 remove all cgi btw. fastcgi dependencies 2024-01-22 19:03:14 +01:00
Peter Hormanns
d95ebd4957 db migration: define useful default settings 2024-01-22 13:36:06 +01:00
Peter Hormanns
85271e0776 fix path to phpstub 2024-01-19 12:02:16 +01:00
Timotheus Pokorra
15ca8d9dd4 protect phpstub with chattr +i and drop chattr -i for deleting domain 2024-01-17 19:59:42 +01:00
Timotheus Pokorra
6e2db93a0f apache vhost: PHP: use FcgidInitialEnv and cgi-bin 2024-01-17 19:49:34 +01:00
Peter Hormanns
bf2a2a885e provide path variables to vhost template 2024-01-17 12:11:24 +01:00
Peter Hormanns
92be4acd7f Merge branch 'TP-202311-vhost-bookworm' of hsh04-dev@dev.hostsharing.net:hostsharing/hs.hsadmin.git into TP-202311-vhost-bookworm 2024-01-17 11:48:36 +01:00
Peter Hormanns
767f47fe7f apache-vhost review 2024-01-17 11:48:05 +01:00
73f47dfb47 Makefile: tomcat7 statt tomcatmq 2024-01-17 11:34:44 +01:00
Peter Hormanns
898aa24be6 Merge branch 'TP-202311-vhost-bookworm' of dev.hostsharing.net:hostsharing/hs.hsadmin into TP-202311-vhost-bookworm 2024-01-17 11:27:45 +01:00
Peter Hormanns
c87ef04330 new domainoption defaults 2024-01-17 11:26:11 +01:00
2268dcc595 Merge branch 'TP-202311-vhost-bookworm' of dev.hostsharing.net:hostsharing/hs.hsadmin into TP-202311-vhost-bookworm 2024-01-12 19:26:26 +01:00
Peter Hormanns
023509d2dd compile in java-8-compatibility mode 2024-01-12 19:16:26 +01:00
39789415a9 Merge branch 'TP-202311-vhost-bookworm' of dev.hostsharing.net:hostsharing/hs.hsadmin into TP-202311-vhost-bookworm 2024-01-12 18:35:32 +01:00
Peter Hormanns
83b7eba59e rollback activemq and openjpa updates 2024-01-12 18:34:35 +01:00
591abcc0fa Merge branch 'TP-202311-vhost-bookworm' of dev.hostsharing.net:hostsharing/hs.hsadmin into TP-202311-vhost-bookworm 2024-01-11 13:19:28 +01:00
Peter Hormanns
471e666215 Merge branch 'TP-202311-vhost-bookworm' of dev.hostsharing.net:hostsharing/hs.hsadmin into TP-202311-vhost-bookworm 2023-12-20 09:21:38 +01:00
Peter Hormanns
caffaaa2a4 Merge branch 'TP-202311-vhost-bookworm' of dev.hostsharing.net:hostsharing/hs.hsadmin into TP-202311-vhost-bookworm 2023-12-19 20:20:22 +01:00
Peter Hormanns
006eef9ab5 domain properties order 2023-12-19 20:20:16 +01:00
Timotheus Pokorra
0ca3cac465 copy hsar.war to tomcatmq after mvn package 2023-12-12 17:54:42 +01:00
Timotheus Pokorra
e2d6e75375 fix passengerfcgiphpbin to fcgiphpbin 2023-12-12 15:12:01 +01:00
Timotheus Pokorra
02e55ee7a3 small fix for default domain options 2023-12-12 14:56:32 +01:00
Peter Hormanns
c4bbde5984 rename setter and getter 2023-12-12 14:38:59 +01:00
Timotheus Pokorra
13316d265e use this 2023-12-12 11:53:25 +01:00
Timotheus Pokorra
9a6a6d094a Erweiterung der Tests um das Ändern von den neuen Domain Eigenschaften, z.B. PassengerPython 2023-12-12 11:52:39 +01:00
Timotheus Pokorra
643b23ad34 Vereinheitlichung der Tests von DomainOptionen 2023-12-12 11:01:19 +01:00
Timotheus Pokorra
fea2612a48 Teste die neuen Domain Optionen 2023-12-12 10:55:37 +01:00
Timotheus Pokorra
0941515461 Add Test for Updating Domain Properties and Domain Options 2023-12-12 00:32:36 +01:00
Timotheus Pokorra
9032f0d81c Makefile hinzufügen für oft auszuführende Operationen 2023-12-11 23:52:26 +01:00
Timotheus Pokorra
e57a3d7c84 fix typos 2023-12-11 17:28:22 +01:00
Timotheus Pokorra
864c21be13 proxy_http_port und proxy_websocket_port zurückgebaut 2023-12-11 17:21:10 +01:00
Timotheus Pokorra
237c6d49fb Undo Änderungen an hsarweb da es nicht mehr im Einsatz ist 2023-12-11 17:14:27 +01:00
Timotheus Pokorra
513431584e Add new domain properties PassengerPython, PassengerNodejs, PassengerRuby, FcgiPhpBin, ProxyHttpPort, ProxyWebsocketPort 2023-11-28 12:48:21 +01:00
Timotheus Pokorra
2c4af11660 Add new domain options passenger, passengerfriendlyerrorpages, cgi and fastcgi 2023-11-28 11:58:51 +01:00
Peter Hormanns
5004cab814 commit changes 2023-11-27 13:40:39 +01:00
43 changed files with 936 additions and 621 deletions

1
.gitignore vendored
View File

@ -1 +0,0 @@
/qserv-test/

40
Makefile Normal file
View File

@ -0,0 +1,40 @@
SHELL := /bin/bash
info:
@echo "Achtung: nur auf Entwicklungs- und Testservern einsetzen!"
@echo "make build: build the jar files"
@echo "make psql: start psql shell on the database"
@echo "make resetdata: reset the data in the database"
@echo "make run: run catalina and watch the output"
@echo "make test: run all continuous integration tests"
@echo "make testdomain: run one specific test for domains"
build:
source ~/.profile
cd ~/hsadmin/util && mvn clean install
cd ~/hsadmin/qserv && mvn clean install
cd ~/hsadmin/hsarback && mvn package -DskipTests
cp ~/hsadmin/qserv/target/hsadmin-*.jar ~/tomcat7/webapps/hsar/WEB-INF/lib/
cp ~/hsadmin/util/target/hsadmin-*.jar ~/tomcat7/webapps/hsar/WEB-INF/lib/
cp ~/hsadmin/hsarback/target/hsar.war ~/tomcat7/webapps
resetdata:
psql -U tim03_hsatest < ~/hsadmin/hsarback/database/dropschema.sql
psql -U tim03_hsatest < ~/hsadmin/hsarback/database/schema.sql
psql -U tim03_hsatest < ~/hsadmin/hsarback/database/data.sql
test: resetdata
source ~/.profile
cd ~/hsadmin/hsarback && mvn test -Dtest=ContinuousIntegrationTest
testdomain: resetdata
source ~/.profile
cd ~/hsadmin/hsarback && mvn test -Dtest=InitDataTest && mvn test -Dtest=DomainTest
run:
source ~/.profile
cd ~/tomcatmq && ./bin/catalina.sh run
psql:
WHOAMI=`whoami` && psql -U $${WHOAMI//\-/_}

View File

@ -209,6 +209,14 @@ INSERT INTO domain_option (domain_option_name)
VALUES ('autoconfig'); VALUES ('autoconfig');
INSERT INTO domain_option (domain_option_name) INSERT INTO domain_option (domain_option_name)
VALUES ('dkim'); VALUES ('dkim');
INSERT INTO domain_option (domain_option_name)
VALUES ('passenger');
INSERT INTO domain_option (domain_option_name)
VALUES ('passengerfriendlyerrorpages');
INSERT INTO domain_option (domain_option_name)
VALUES ('cgi');
INSERT INTO domain_option (domain_option_name)
VALUES ('fastcgi');
-- --
-- table: price_list -- table: price_list

View File

@ -1,85 +1,19 @@
DROP VIEW ipconfig;
ALTER TABLE packet ALTER TABLE domain
ALTER COLUMN packet_name TYPE VARCHAR(6); ADD COLUMN passenger_python character varying(256) DEFAULT '/usr/bin/python3',
ALTER TABLE packet ADD COLUMN passenger_nodejs character varying(256) DEFAULT '/usr/bin/node',
ALTER COLUMN hive_id DROP NOT NULL; ADD COLUMN passenger_ruby character varying(256) DEFAULT '/usr/bin/ruby',
ADD COLUMN fcgi_php_bin character varying(256) DEFAULT '/usr/lib/cgi-bin/php';
UPDATE packet SET packet_name='vm10' || substr(packet_name,4,2) WHERE packet_name LIKE 'srv%'; INSERT INTO domain_option (domain_option_name) VALUES
('passenger'),
('passengerfriendlyerrorpages'),
('cgi'),
('fastcgi');
CREATE VIEW ipconfig AS INSERT INTO domain__domain_option ( domain_option_id, domain_id )
SELECT DISTINCT ON (theunion.ipv4) theunion.ipv4, SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='cgi' ), domain_id FROM domain;
theunion.name, INSERT INTO domain__domain_option ( domain_option_id, domain_id )
theunion.alias, SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='fastcgi' ), domain_id FROM domain;
theunion.hivename INSERT INTO domain__domain_option ( domain_option_id, domain_id )
FROM ( SELECT h.hive_name AS hivename, SELECT ( SELECT domain_option_id FROM domain_option WHERE domain_option_name='passenger' ), domain_id FROM domain;
ip.inet_addr AS ipv4,
'eth0:'::text || p.packet_name::text AS alias,
p.packet_name AS name,
2 AS prio
FROM inet_addr ip
JOIN packet p ON p.cur_inet_addr_id = ip.inet_addr_id
JOIN hive h ON h.hive_id = p.hive_id
UNION
SELECT h.hive_name AS hivename,
ip.inet_addr AS ipv4,
'eth0'::text AS alias,
h.hive_name AS name,
1 AS prio
FROM inet_addr ip
JOIN hive h ON h.inet_addr_id = ip.inet_addr_id
ORDER BY 2, 5) theunion;
INSERT INTO basepacket (basepacket_code, description, sorting, valid, article_number)
VALUES ('SRV/CLD', 'Cloud Server', 0, true, 3000);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('BANDWIDTH', 'Bandbreite 95/5 (Mbit/s)', 0, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('SLAINFR8H', 'HS Ext. Support (24x7 8h) for Infrastructure', 0, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('SLAINFR4H', 'HS Ext. Support (24x7 4h) for Infrastructure', 0, true);
INSERT INTO basecomponent (basecomponent_code, description, sorting, valid)
VALUES ('SLAINFR2H', 'HS Ext. Support (24x7 2h) for Infrastructure', 0, true);
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 1, 102400000, 1, 1, 0, false, 3011 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='CPU';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 1024, 102400000, 1024, 1024, 0, false, 3012 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='RAM';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 102400000, 250, 250, 0, false, 3013 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='TRAFFIC';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1000, 0, 1, 0, false, 3017 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='BANDWIDTH';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 25600, 102400000, 25600, 25600, 0, false, 3014 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='QUOTA';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 102400000, 0, 256000, 0, false, 3015 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='STORAGE';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 1, 1, 1, 1, 0, false, 3136 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLABASIC';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3122 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR8H';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3125 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR4H';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1, 0, 1, 0, false, 3151 FROM basepacket, basecomponent WHERE basepacket_code='SRV/CLD' AND basecomponent_code='SLAINFR2H';
INSERT INTO component (basepacket_id, basecomponent_id, min_quantity, max_quantity, default_quantity, increment_quantity, include_quantity, admin_only, article_number)
SELECT basepacket_id, basecomponent_id, 0, 1000, 0, 1, 0, false, 2017 FROM basepacket, basecomponent WHERE basepacket_code='SRV/MGD' AND basecomponent_code='BANDWIDTH';
UPDATE component SET min_quantity=0 WHERE component_id=38; -- min. Traffic für Managed Server auf 0
INSERT INTO price (article_number, price, vat, price_list) VALUES (3011, 15, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3012, 5, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3013, 5, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3014, 5, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3015, 5, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3017, 2, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3136, 10, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3122, 40, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3125, 80, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (3151, 160, 19.0, 1);
INSERT INTO price (article_number, price, vat, price_list) VALUES (2017, 2, 19.0, 1);

View File

@ -319,7 +319,11 @@ CREATE TABLE domain (
domain_dns_master character varying(64), domain_dns_master character varying(64),
domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL, domain_id integer DEFAULT nextval('domain_domain_id_seq'::regclass) NOT NULL,
domain_owner integer NOT NULL, domain_owner integer NOT NULL,
valid_subdomain_names character varying(256) DEFAULT 'www' NOT NULL valid_subdomain_names character varying(256) DEFAULT 'www' NOT NULL,
passenger_python character varying(256) NULL,
passenger_nodejs character varying(256) NULL,
passenger_ruby character varying(256) NULL,
fcgi_php_bin character varying(256) NULL
); );

View File

@ -5,26 +5,43 @@
<groupId>de.hsadmin</groupId> <groupId>de.hsadmin</groupId>
<artifactId>hsar</artifactId> <artifactId>hsar</artifactId>
<packaging>war</packaging> <packaging>war</packaging>
<version>4.0.18</version> <version>4.0.15</version>
<name>HSAdmin Stable Backend Webapp</name> <name>HSAdmin Stable Backend Webapp</name>
<url>http://maven.apache.org</url> <url>http://maven.apache.org</url>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<maven.compiler.source>11</maven.compiler.source> <maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target> <maven.compiler.target>8</maven.compiler.target>
<maven.test.skip>true</maven.test.skip>
</properties> </properties>
<profiles>
<profile>
<id>local</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/local-resources</directory>
</resource>
</resources>
</build>
</profile>
</profiles>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>de.hsadmin.core</groupId> <groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-util</artifactId> <artifactId>hsadmin-util</artifactId>
<version>4.0.18</version> <version>4.0.15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>de.hsadmin.core</groupId> <groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-qserv</artifactId> <artifactId>hsadmin-qserv</artifactId>
<version>4.0.18</version> <version>4.0.15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-httpclient</groupId> <groupId>commons-httpclient</groupId>
@ -53,18 +70,13 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId> <artifactId>velocity</artifactId>
<version>2.3</version> <version>1.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.openjpa</groupId> <groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId> <artifactId>openjpa</artifactId>
<version>3.2.2</version> <version>2.4.3</version>
</dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId>
<version>5.17.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -78,6 +90,18 @@
<version>4.0.1</version> <version>4.0.1</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>activemq-all</artifactId>
<version>5.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>hsar</finalName> <finalName>hsar</finalName>
@ -92,8 +116,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version> <version>3.11.0</version>
<configuration> <configuration>
<source>11</source> <source>8</source>
<target>11</target> <target>8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -51,6 +51,14 @@ public class DomainRemote extends AbstractRemote {
} }
final String validsubdomains = dom.getValidsubdomainnames(); final String validsubdomains = dom.getValidsubdomainnames();
resultMap.put("validsubdomainnames", validsubdomains); resultMap.put("validsubdomainnames", validsubdomains);
final String passengerpython = dom.getPassengerpython();
resultMap.put("passengerpython", passengerpython);
final String passengernodejs = dom.getPassengernodejs();
resultMap.put("passengernodejs", passengernodejs);
final String passengerruby = dom.getPassengerruby();
resultMap.put("passengerruby", passengerruby);
final String fcgiphpbin = dom.getFcgiphpbin();
resultMap.put("fcgiphpbin", fcgiphpbin);
} }
@Override @Override
@ -92,6 +100,22 @@ public class DomainRemote extends AbstractRemote {
if (validsubdomains != null && validsubdomains instanceof String) { if (validsubdomains != null && validsubdomains instanceof String) {
dom.setValidsubdomainnames((String) validsubdomains); dom.setValidsubdomainnames((String) validsubdomains);
} }
final Object passengerpython = setParams.get("passengerpython");
if (passengerpython != null && passengerpython instanceof String) {
dom.setPassengerpython((String) passengerpython);
}
final Object passengernodejs = setParams.get("passengernodejs");
if (passengernodejs != null && passengernodejs instanceof String) {
dom.setPassengernodejs((String) passengernodejs);
}
final Object passengerruby = setParams.get("passengerruby");
if (passengerruby != null && passengerruby instanceof String) {
dom.setPassengerruby((String) passengerruby);
}
final Object fcgiphpbin = setParams.get("fcgiphpbin");
if (fcgiphpbin != null && fcgiphpbin instanceof String) {
dom.setFcgiphpbin((String) fcgiphpbin);
}
} }
@Override @Override

View File

@ -23,9 +23,8 @@ public class RoleRemote implements IRemote {
Transaction transaction = new Transaction(user); Transaction transaction = new Transaction(user);
if (transaction.login(user, ticket)) { if (transaction.login(user, ticket)) {
String role = "USER"; String role = "USER";
Config config = Config.getInstance(); String accoutPrefixCustomer = Config.getInstance().getProperty("accountprefix.customer");
String accoutPrefixCustomer = config.getProperty("accountprefix.customer"); String accoutPrefixHostmaster = Config.getInstance().getProperty("accountprefix.hostmaster");
String accoutPrefixHostmaster = config.getProperty("accountprefix.hostmaster");
Pac pac = transaction.getLoginUser().getPac(); Pac pac = transaction.getLoginUser().getPac();
String pacName = pac.getName(); String pacName = pac.getName();
if (accoutPrefixCustomer.equals(pacName)) { if (accoutPrefixCustomer.equals(pacName)) {

View File

@ -121,6 +121,10 @@ public class JsonPillarServlet extends HttpServlet {
domainadmins.add(domUserName); domainadmins.add(domUserName);
final Pac domPac = domUser.getPac(); final Pac domPac = domUser.getPac();
final String validSubdomainNames = dom.getValidsubdomainnames(); final String validSubdomainNames = dom.getValidsubdomainnames();
final String passengerPython = dom.getPassengerpython();
final String passengerNodejs = dom.getPassengernodejs();
final String passengerRuby = dom.getPassengerruby();
final String fcgiPhpBin = dom.getFcgiphpbin();
final INetAddress domINetAddr = domPac.getCurINetAddr(); final INetAddress domINetAddr = domPac.getCurINetAddr();
writer.println(" \"domain\": \"" + domName + "\""); writer.println(" \"domain\": \"" + domName + "\"");
writer.println(" , \"pac\": \"" + domPac.getName() + "\""); writer.println(" , \"pac\": \"" + domPac.getName() + "\"");
@ -148,6 +152,18 @@ public class JsonPillarServlet extends HttpServlet {
} }
writer.println(" }"); writer.println(" }");
writer.println(" , \"validsubdomains\": \"" + validSubdomainNames + "\""); writer.println(" , \"validsubdomains\": \"" + validSubdomainNames + "\"");
if (passengerPython != null && passengerPython.length() > 0) {
writer.println(" , \"passengerpython\": \"" + passengerPython + "\"");
}
if (passengerNodejs != null && passengerNodejs.length() > 0) {
writer.println(" , \"passengernodejs\": \"" + passengerNodejs + "\"");
}
if (passengerRuby != null && passengerRuby.length() > 0) {
writer.println(" , \"passengerruby\": \"" + passengerRuby + "\"");
}
if (fcgiPhpBin != null && fcgiPhpBin.length() > 0) {
writer.println(" , \"fcgiphpbin\": \"" + fcgiPhpBin + "\"");
}
writer.println(" }"); writer.println(" }");
} }
writer.println(" ]"); writer.println(" ]");

View File

@ -0,0 +1,25 @@
package de.hsadmin.servlets;
import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import de.hsadmin.core.model.PersistenceManager;
public class PersistenceManagerContextListener implements ServletContextListener {
public PersistenceManagerContextListener() {
}
@Override
public void contextDestroyed(ServletContextEvent contextEvent) {
System.out.println("PersistenceManager.contextDestroyed()");
PersistenceManager.close();
}
@Override
public void contextInitialized(ServletContextEvent contextEvent) {
// do nothing
}
}

View File

@ -2,8 +2,6 @@ package de.hsadmin.servlets;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.io.Serializable;
import java.util.Date;
import javax.jms.ExceptionListener; import javax.jms.ExceptionListener;
import javax.jms.JMSException; import javax.jms.JMSException;
@ -12,9 +10,13 @@ import javax.jms.MessageListener;
import javax.jms.ObjectMessage; import javax.jms.ObjectMessage;
import javax.jms.Queue; import javax.jms.Queue;
import javax.jms.QueueConnection; import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver; import javax.jms.QueueReceiver;
import javax.jms.QueueSession; import javax.jms.QueueSession;
import javax.jms.Session; import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.servlet.ServletConfig; import javax.servlet.ServletConfig;
import javax.servlet.ServletException; import javax.servlet.ServletException;
@ -22,14 +24,11 @@ import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import org.apache.activemq.ActiveMQConnectionFactory;
import de.hsadmin.core.model.TechnicalException; import de.hsadmin.core.model.TechnicalException;
import de.hsadmin.core.model.TicketValidator; import de.hsadmin.core.model.TicketValidator;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
import de.hsadmin.core.qserv.Processor; import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.qserv.TaskTransfer;
import de.hsadmin.core.util.Config; import de.hsadmin.core.util.Config;
public class QueueStatusReceiverServlet extends HttpServlet public class QueueStatusReceiverServlet extends HttpServlet
@ -37,10 +36,9 @@ public class QueueStatusReceiverServlet extends HttpServlet
private static final long serialVersionUID = -5701350884034782083L; private static final long serialVersionUID = -5701350884034782083L;
private String jmsUrl;
private String jmsUser; private String jmsUser;
private String jmsPass; private String jmsPass;
private String jmsStatusQueue; private QueueConnectionFactory queueConnectionFactory;
private QueueConnection queueConnection; private QueueConnection queueConnection;
private QueueSession queueSession; private QueueSession queueSession;
private boolean isConnected; private boolean isConnected;
@ -56,24 +54,27 @@ public class QueueStatusReceiverServlet extends HttpServlet
isConnected = false; isConnected = false;
messageCount = 0; messageCount = 0;
errorCount = 0; errorCount = 0;
try {
connect(); connect();
} catch (NamingException e) {
throw new ServletException(e);
}
} }
private void connect() { private void connect() throws NamingException {
Config config = Config.getInstance(); Config config = Config.getInstance();
jmsUrl = config.getProperty("hsadmin.jms.url", "tcp://localhost:61616");
jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin"); jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw"); jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
jmsStatusQueue = config.getProperty("hsadmin.jms.status-queue", "queue.Status"); InitialContext ctx = new InitialContext();
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl); Context env = (Context) ctx.lookup("java:comp/env");
mqConnectionFactory.setTrustAllPackages(true); queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
int timeoutCounter = 10; int timeoutCounter = 10;
while (!isConnected && (timeoutCounter > 0)) { while (!isConnected && (timeoutCounter > 0)) {
try { try {
queueConnection = mqConnectionFactory.createQueueConnection(jmsUser, jmsPass); queueConnection = queueConnectionFactory.createQueueConnection(jmsUser, jmsPass);
queueConnection.setExceptionListener(this); queueConnection.setExceptionListener(this);
queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); queueSession = queueConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
Queue queue = queueSession.createQueue(jmsStatusQueue); Queue queue = (Queue) env.lookup("jms/hsadminStatus");
queueConnection.start(); queueConnection.start();
QueueReceiver receiver = queueSession.createReceiver(queue); QueueReceiver receiver = queueSession.createReceiver(queue);
receiver.setMessageListener(this); receiver.setMessageListener(this);
@ -112,24 +113,16 @@ public class QueueStatusReceiverServlet extends HttpServlet
@Override @Override
public void onMessage(Message jmsMessage) { public void onMessage(Message jmsMessage) {
assert jmsMessage != null;
Transaction transaction = null; Transaction transaction = null;
messageCount++; messageCount++;
try { try {
ObjectMessage objMessage = (ObjectMessage) jmsMessage; ObjectMessage objMessage = (ObjectMessage) jmsMessage;
final Serializable object = objMessage.getObject(); QueueTask detachedQT = (QueueTask) objMessage.getObject();
if (object != null) {
TaskTransfer detachedQT = (TaskTransfer) object;
transaction = new Transaction("statusreceiver"); transaction = new Transaction("statusreceiver");
transaction.beginTransaction(); transaction.beginTransaction();
EntityManager em = transaction.getEntityManager(); EntityManager em = transaction.getEntityManager();
em.clear(); em.clear();
final long queueTaskId = detachedQT.getId(); QueueTask persistentQT = em.find(QueueTask.class, detachedQT.getId());
QueueTask persistentQT = em.find(QueueTask.class, queueTaskId);
if (persistentQT == null) {
errorCount++;
throw new TechnicalException("QueueTask not found, id: " + queueTaskId);
}
persistentQT.assign(detachedQT); persistentQT.assign(detachedQT);
Processor processor = persistentQT.getProcessor(); Processor processor = persistentQT.getProcessor();
if (processor != null) { if (processor != null) {
@ -138,12 +131,6 @@ public class QueueStatusReceiverServlet extends HttpServlet
em.persist(persistentQT); em.persist(persistentQT);
em.flush(); em.flush();
transaction.commitTransaction(); transaction.commitTransaction();
} else {
errorCount++;
final String err = "Deserialization failed " + new Date();
System.out.println(err);
throw new TechnicalException(err);
}
} catch (Exception e) { } catch (Exception e) {
errorCount++; errorCount++;
if (transaction != null) transaction.rollbackTransaction(); if (transaction != null) transaction.rollbackTransaction();
@ -157,7 +144,7 @@ public class QueueStatusReceiverServlet extends HttpServlet
public void onException(JMSException exception) { public void onException(JMSException exception) {
close(); close();
try { Thread.sleep(10000); } catch (InterruptedException e) { } try { Thread.sleep(10000); } catch (InterruptedException e) { }
connect(); try { connect(); } catch (NamingException e) { }
} }
} }

View File

@ -17,8 +17,12 @@
DocumentRoot /home/doms/${dom.name}/htdocs DocumentRoot /home/doms/${dom.name}/htdocs
#if( ${cgi} )
Alias /cgi-bin/ /home/doms/${dom.name}/cgi/ Alias /cgi-bin/ /home/doms/${dom.name}/cgi/
#end
#if( ${fastcgi} )
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/ Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi/
#end
<Directory /> <Directory />
PassengerEnabled Off PassengerEnabled Off
@ -26,21 +30,42 @@
</Directory> </Directory>
<Directory /home/doms/${dom.name}/> <Directory /home/doms/${dom.name}/>
#if( ${passenger} )
PassengerEnabled On PassengerEnabled On
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv # PassengerPreloadBundler On
#else
PassengerEnabled Off
#end
#if( ${passengerfriendlyerrorpages} )
PassengerFriendlyErrorPages On
#end
#if( ${passengerpython} )
PassengerPython ${passengerpython}
#end
#if( ${passengernodejs} )
PassengerNodejs ${passengernodejs}
#end
#if( ${passengerruby} )
PassengerRuby ${passengerruby}
#end
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
</Directory> </Directory>
#if( ${cgi} )
<Location /cgi-bin/> <Location /cgi-bin/>
PassengerEnabled Off PassengerEnabled Off
SetHandler cgi-script SetHandler cgi-script
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
</Location> </Location>
#end
#if( ${fastcgi} )
<Location /fastcgi-bin/> <Location /fastcgi-bin/>
PassengerEnabled Off PassengerEnabled Off
SetHandler fcgid-script SetHandler fcgid-script
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
</Location> </Location>
#end
#if( ${autoconfig} ) #if( ${autoconfig} )
<Location /autodiscover/autodiscover.xml> <Location /autodiscover/autodiscover.xml>
@ -57,8 +82,12 @@
RewriteEngine On RewriteEngine On
RewriteOptions Inherit RewriteOptions Inherit
#if( ${cgi} )
RewriteCond %{REQUEST_URI} !^/cgi-bin/ RewriteCond %{REQUEST_URI} !^/cgi-bin/
#end
#if( ${fastcgi} )
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
#end
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]
@ -71,8 +100,13 @@
RewriteRule ^(.*) - [redirect=404,last] RewriteRule ^(.*) - [redirect=404,last]
#end #end
AddType application/x-httpd-php .php .php5 .php4 .php3 #if( ${fastcgi} )
Action application/x-httpd-php /fastcgi-bin/phpstub #if( ${fcgiphpbin} )
FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin}
#end
AddType application/x-httpd-php .php
Action application/x-httpd-php /fastcgi-bin/hs-phpstub
#end
</VirtualHost> </VirtualHost>
<VirtualHost ${pac.curINetAddr.inet4Addr}:443 ${pac.oldINetAddr.inet4Addr}:443 [${pac.curINetAddr.inet6Addr}]:443 [${pac.oldINetAddr.inet6Addr}]:443> <VirtualHost ${pac.curINetAddr.inet4Addr}:443 ${pac.oldINetAddr.inet4Addr}:443 [${pac.curINetAddr.inet6Addr}]:443 [${pac.oldINetAddr.inet6Addr}]:443>
@ -94,8 +128,12 @@
DocumentRoot /home/doms/${dom.name}/htdocs-ssl DocumentRoot /home/doms/${dom.name}/htdocs-ssl
#if( ${cgi} )
Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/ Alias /cgi-bin/ /home/doms/${dom.name}/cgi-ssl/
#end
#if( ${fastcgi} )
Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/ Alias /fastcgi-bin/ /home/doms/${dom.name}/fastcgi-ssl/
#end
<Directory /> <Directory />
SSLRequireSSL On SSLRequireSSL On
@ -104,21 +142,42 @@
</Directory> </Directory>
<Directory /home/doms/${dom.name}/> <Directory /home/doms/${dom.name}/>
#if( ${passenger} )
PassengerEnabled On PassengerEnabled On
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,IncludesNoExec,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv # PassengerPreloadBundler On
#else
PassengerEnabled Off
#end
#if( ${passengerfriendlyerrorpages} )
PassengerFriendlyErrorPages On
#end
#if( ${passengerpython} )
PassengerPython ${passengerpython}
#end
#if( ${passengernodejs} )
PassengerNodejs ${passengernodejs}
#end
#if( ${passengerruby} )
PassengerRuby ${passengerruby}
#end
AllowOverride AuthConfig FileInfo Indexes Limit Options=ExecCGI,Includes,Indexes,MultiViews,SymLinksIfOwnerMatch,PassengerNodejs,PassengerPython,PassengerRuby,PassengerAppEnv
</Directory> </Directory>
#if( ${cgi} )
<Location /cgi-bin/> <Location /cgi-bin/>
PassengerEnabled Off PassengerEnabled Off
SetHandler cgi-script SetHandler cgi-script
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
</Location> </Location>
#end
#if( ${fastcgi} )
<Location /fastcgi-bin/> <Location /fastcgi-bin/>
PassengerEnabled Off PassengerEnabled Off
SetHandler fcgid-script SetHandler fcgid-script
Options +ExecCGI +IncludesNoExec -Indexes -MultiViews +SymLinksIfOwnerMatch Options +ExecCGI +Includes -Indexes -MultiViews +SymLinksIfOwnerMatch
</Location> </Location>
#end
#if( ${autoconfig} ) #if( ${autoconfig} )
<Location /autodiscover/autodiscover.xml> <Location /autodiscover/autodiscover.xml>
@ -135,8 +194,12 @@
RewriteEngine On RewriteEngine On
RewriteOptions Inherit RewriteOptions Inherit
#if( ${cgi} )
RewriteCond %{REQUEST_URI} !^/cgi-bin/ RewriteCond %{REQUEST_URI} !^/cgi-bin/
#end
#if( ${fastcgi} )
RewriteCond %{REQUEST_URI} !^/fastcgi-bin/ RewriteCond %{REQUEST_URI} !^/fastcgi-bin/
#end
RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary] RewriteCond %{HTTP_HOST} ^(.+)\.${dom.name}\.?(:[0-9]+)?$ [novary]
RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# -d RewriteCond /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1} ]]# -d
RewriteRule ^(.*) /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1}$1 ]]# [last] RewriteRule ^(.*) /home/doms/${dom.name}/subs-ssl/#[[${tolower:%1}$1 ]]# [last]
@ -149,7 +212,11 @@
RewriteRule ^(.*) - [redirect=404,last] RewriteRule ^(.*) - [redirect=404,last]
#end #end
AddType application/x-httpd-php .php .php5 .php4 .php3 #if( ${fastcgi} )
Action application/x-httpd-php /fastcgi-bin/phpstub #if( ${fcgiphpbin} )
FcgidInitialEnv HTTP_PHP_BIN ${fcgiphpbin}
#end
AddType application/x-httpd-php .php
Action application/x-httpd-php /fastcgi-bin/hs-phpstub
#end
</VirtualHost> </VirtualHost>

View File

@ -5,4 +5,29 @@
global="jdbc/HSAdminDB" global="jdbc/HSAdminDB"
type="javax.sql.DataSource"/> type="javax.sql.DataSource"/>
<ResourceLink
name="jms/QueueCF"
global="jms/QueueCF"
type="javax.jms.QueueConnectionFactory"/>
<ResourceLink
name="jms/hsadminSystem-h99"
global="jms/hsadminSystem-h99"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-testmail"
global="jms/hsadminSystem-testmail"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminSystem-testdns"
global="jms/hsadminSystem-testdns"
type="javax.jms.Queue"/>
<ResourceLink
name="jms/hsadminStatus"
global="jms/hsadminStatus"
type="javax.jms.Queue"/>
</Context> </Context>

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<persistence version="2.0" xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd">
<persistence-unit name="hsadmin" transaction-type="RESOURCE_LOCAL">
<provider>org.apache.openjpa.persistence.PersistenceProviderImpl</provider>
<non-jta-data-source>java:/comp/env/jdbc/HSAdminDB</non-jta-data-source>
<class>de.hsadmin.core.qserv.QueueTask</class>
<class>de.hsadmin.mods.cust.Customer</class>
<class>de.hsadmin.mods.cust.Contact</class>
<class>de.hsadmin.mods.pac.Pac</class>
<class>de.hsadmin.mods.pac.BasePac</class>
<class>de.hsadmin.mods.pac.BaseComponent</class>
<class>de.hsadmin.mods.pac.Component</class>
<class>de.hsadmin.mods.pac.PacComponent</class>
<class>de.hsadmin.mods.pac.Hive</class>
<class>de.hsadmin.mods.pac.INetAddress</class>
<class>de.hsadmin.mods.user.UnixUser</class>
<class>de.hsadmin.mods.dom.Domain</class>
<class>de.hsadmin.mods.dom.DomainOption</class>
<class>de.hsadmin.mods.email.EMailAddress</class>
<class>de.hsadmin.mods.email.EMailAlias</class>
<class>de.hsadmin.mods.db.DatabaseUser</class>
<class>de.hsadmin.mods.db.MySqlUser</class>
<class>de.hsadmin.mods.db.PgSqlUser</class>
<class>de.hsadmin.mods.db.Database</class>
<class>de.hsadmin.mods.db.MySqlDatabase</class>
<class>de.hsadmin.mods.db.PgSqlDatabase</class>
<properties>
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/>
<property name="openjpa.Compatibility" value="QuotedNumbersInQueries=true"/>
<property name="openjpa.Log" value="SQL=TRACE"/>
<property name="openjpa.ConnectionFactoryProperties" value="PrettyPrint=true, PrettyPrintLineLength=72"/>
</properties>
</persistence-unit>
</persistence>

View File

@ -4,6 +4,10 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5"> version="2.5">
<listener>
<listener-class>de.hsadmin.servlets.PersistenceManagerContextListener</listener-class>
</listener>
<servlet> <servlet>
<servlet-name>Queue Status Servlet</servlet-name> <servlet-name>Queue Status Servlet</servlet-name>
<servlet-class>de.hsadmin.servlets.QueueStatusReceiverServlet</servlet-class> <servlet-class>de.hsadmin.servlets.QueueStatusReceiverServlet</servlet-class>
@ -53,5 +57,36 @@
<res-auth>Container</res-auth> <res-auth>Container</res-auth>
</resource-ref> </resource-ref>
</web-app> <resource-ref>
<res-ref-name>jms/QueueCF</res-ref-name>
<res-type>javax.jms.QueueConnectionFactory</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
<resource-ref>
<res-ref-name>jms/hsadminSystem-h99</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-testdns</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-testmail</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/hsadminStatus</res-ref-name>
<res-type>javax.jms.Queue</res-type>
<res-auth>Container</res-auth>
<res-sharing-scope>Shareable</res-sharing-scope>
</resource-ref>
</web-app>

View File

@ -9,6 +9,7 @@ import java.io.IOException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Arrays;
import org.apache.xmlrpc.XmlRpcException; import org.apache.xmlrpc.XmlRpcException;
import org.apache.xmlrpc.client.XmlRpcClient; import org.apache.xmlrpc.client.XmlRpcClient;
@ -61,7 +62,7 @@ public class DomainTest {
} }
@Test @Test
public void testUpdate() { public void testUpdateWithoutPermissionFail() {
String user = "aaa00"; String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user); String grantingTicketURL = cas.getGrantingTicketURL(user);
Map<String, String> setParams = new HashMap<String, String>(); Map<String, String> setParams = new HashMap<String, String>();
@ -99,6 +100,129 @@ public class DomainTest {
assertEquals(count + 1, getDomsCount()); assertEquals(count + 1, getDomsCount());
} }
@Test
public void testUpdateDomain() {
String user = "aaa00";
String grantingTicketURL = cas.getGrantingTicketURL(user);
// first create the domain
Map<String, Object> setParams = new HashMap<String, Object>();
setParams.put("name", "exampleupdate.de");
setParams.put("user", "aaa00-admin");
Object[] params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams };
try {
Object execute = client.execute(MODULE + ".add", params);
assertTrue(execute instanceof Map<?, ?>);
} catch (XmlRpcException e) {
fail(e.getMessage());
}
// check initial values
Map<String, String> whereParams = new HashMap<String, String>();
whereParams.put("name", "exampleupdate.de");
params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
whereParams };
try {
Object execute = client.execute(MODULE + ".search", params);
if (execute instanceof Object[]) {
Object[] result = (Object[]) execute;
assertTrue("expected 1 result, but got " + result.length, 1 == result.length);
for (Object o : result) {
if (o instanceof Map<?, ?>) {
Map<?, ?> row = (Map<?, ?>) o;
assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name")));
assertTrue("ValidSubdomainNames should be * but is " + row.get("validsubdomainnames"), "*".equals(row.get("validsubdomainnames")));
String defaultPassengerPython = "";
assertTrue("PassengerPython should be empty but is " + row.get("passengerpython"), isNullOrEmpty(row.get("passengerpython")));
assertTrue("PassengerNodejs should be empty but is " + row.get("passengernodejs"), isNullOrEmpty(row.get("passengernodejs")));
assertTrue("PassengerRuby should be empty but is " + row.get("passengerruby"), isNullOrEmpty(row.get("passengerruby")));
assertTrue("FcgiPhpBin should be empty but is " + row.get("fcgiphpbin"), isNullOrEmpty(row.get("fcgiphpbin")));
String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]);
String[] expectedDomainOptions = new String[] {"htdocsfallback", "cgi", "fastcgi", "passenger", "indexes", "dkim", "autoconfig", "greylisting", "includes", "letsencrypt", "multiviews"};
Arrays.sort(expectedDomainOptions);
Arrays.sort(checkDomainOptions);
assertTrue("Default Domainoptions should be " + Arrays.toString(expectedDomainOptions) + " but are " + Arrays.toString(checkDomainOptions),
Arrays.toString(expectedDomainOptions).equals(Arrays.toString(checkDomainOptions)));
}
else {
fail("Map<?, ?> expected");
}
}
}
else {
fail("Object[] expected");
}
} catch (XmlRpcException e) {
fail(e.getMessage());
}
// now update the domain
setParams = new HashMap<String, Object>();
setParams.put("validsubdomainnames", "www2");
String newPassengerPython = "/home/pacs/aaa00/users/admin/.venv/bin/python3";
setParams.put("passengerpython", newPassengerPython);
String newPassengerRuby = "/home/pacs/aaa00/users/admin/.rbenv/shims/ruby";
setParams.put("passengerruby", newPassengerRuby);
String newPassengerNodejs = "/home/pacs/aaa00/users/admin/.nvm/versions/node/v18.19.0/bin/node";
setParams.put("passengernodejs", newPassengerNodejs);
String newFcgiPhpBin = "/usr/lib/cgi-bin/php8.1";
setParams.put("fcgiphpbin", newFcgiPhpBin);
String[] newDomainOptions = new String[] {"greylisting", "letsencrypt", "passenger", "passengerfriendlyerrorpages", "cgi", "fastcgi"};
setParams.put("domainoptions", newDomainOptions);
whereParams = new HashMap<String, String>();
whereParams.put("name", "exampleupdate.de");
params = new Object[] { user,
cas.getServiceTicket(grantingTicketURL, RemoteTestHelper.getBackendURL()),
setParams, whereParams };
try {
Object execute = client.execute(MODULE + ".update", params);
if (execute instanceof Object[]) {
Object[] result = (Object[]) execute;
assertTrue("expected 1 result, but got " + result.length, 1 == result.length);
for (Object o : result) {
if (o instanceof Map<?, ?>) {
Map<?, ?> row = (Map<?, ?>) o;
assertTrue("Domain name should be exampleupdate.de but is " + row.get("name"), "exampleupdate.de".equals(row.get("name")));
assertTrue("ValidSubdomainNames should be www2 but is " + row.get("validsubdomainnames"), "www2".equals(row.get("validsubdomainnames")));
assertTrue("PassengerPython should be " + newPassengerPython + " but is " + row.get("passengerpython"), newPassengerPython.equals(row.get("passengerpython")));
assertTrue("PassengerNodejs should be " + newPassengerNodejs + " but is " + row.get("passengernodejs"), newPassengerNodejs.equals(row.get("passengernodejs")));
assertTrue("PassengerRuby should be " + newPassengerRuby + " but is " + row.get("passengerruby"), newPassengerRuby.equals(row.get("passengerruby")));
assertTrue("FcgiPhpBin should be " + newFcgiPhpBin + " but is " + row.get("fcgiphpbin"), newFcgiPhpBin.equals(row.get("fcgiphpbin")));
String[] checkDomainOptions = Arrays.asList((Object[]) row.get("domainoptions")).toArray(new String[0]);
Arrays.sort(newDomainOptions);
Arrays.sort(checkDomainOptions);
assertTrue("Domainoptions should be " + Arrays.toString(newDomainOptions) + " but are " + Arrays.toString(checkDomainOptions),
Arrays.toString(newDomainOptions).equals(Arrays.toString(checkDomainOptions)));
}
else {
fail("Map<?, ?> expected");
}
}
}
else {
fail("Object[] expected");
}
} catch (XmlRpcException e) {
fail(e.getMessage());
}
}
private Boolean isNullOrEmpty(Object s) {
if (s == null) return true;
if (((String)s).equals("")) return true;
return false;
}
@Test @Test
public void testCreateForeignSubdomain() throws UnknownHostException, IOException { public void testCreateForeignSubdomain() throws UnknownHostException, IOException {
int count = getDomsCount(); int count = getDomsCount();

View File

@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.hsadmin</groupId> <groupId>de.hsadmin</groupId>
<artifactId>hsadmin-qserv</artifactId> <artifactId>hsadmin-qserv</artifactId>
<version>4.0.18</version> <version>4.0.15</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>HSAdmin-QServ</name> <name>HSAdmin-QServ</name>
@ -17,15 +17,10 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-util</artifactId>
<version>4.0.18</version>
</dependency>
<dependency> <dependency>
<groupId>de.hsadmin.core</groupId> <groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-qserv</artifactId> <artifactId>hsadmin-qserv</artifactId>
<version>4.0.18</version> <version>4.0.15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
@ -84,15 +79,6 @@
<prefix>/usr/local/lib/hostsharing/hsadmin</prefix> <prefix>/usr/local/lib/hostsharing/hsadmin</prefix>
</mapper> </mapper>
</data> </data>
<data>
<src>src/deb/init/init_hive_mysqldb.sh</src>
<type>file</type>
<mapper>
<type>perm</type>
<prefix>/usr/local/lib/hostsharing/hsadmin/tools/</prefix>
<filemode>754</filemode>
</mapper>
</data>
<data> <data>
<src>src/deb/systemd/hsadmin-qserv.service</src> <src>src/deb/systemd/hsadmin-qserv.service</src>
<type>file</type> <type>file</type>

View File

@ -1,50 +0,0 @@
#!/bin/bash
mysql --defaults-file=/root/.my.cnf mysql <<EOSQL
DROP PROCEDURE IF EXISTS kill_by_user;
DROP PROCEDURE IF EXISTS kill_by_database;
DELIMITER //
CREATE PROCEDURE kill_by_user (IN user_name VARCHAR(64) CHARSET utf8)
BEGIN
DECLARE query_id INT;
DECLARE iteration_complete INT DEFAULT 0;
DECLARE select_cursor CURSOR FOR SELECT id FROM information_schema.processlist WHERE user = user_name;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iteration_complete=1;
OPEN select_cursor;
cursor_loop: LOOP
FETCH select_cursor INTO query_id;
IF iteration_complete THEN
LEAVE cursor_loop;
END IF;
KILL query_id;
END LOOP;
CLOSE select_cursor;
END
//
CREATE PROCEDURE kill_by_database (IN database_name VARCHAR(64))
BEGIN
DECLARE query_id INT;
DECLARE iteration_complete INT DEFAULT 0;
DECLARE select_cursor CURSOR FOR SELECT id FROM information_schema.processlist WHERE db = database_name;
DECLARE CONTINUE HANDLER FOR NOT FOUND SET iteration_complete=1;
OPEN select_cursor;
cursor_loop: LOOP
FETCH select_cursor INTO query_id;
IF iteration_complete THEN
LEAVE cursor_loop;
END IF;
KILL query_id;
END LOOP;
CLOSE select_cursor;
END
//
DELIMITER ;
EOSQL
echo "installed mysql procedures for hsadmin-qserv"

View File

@ -4,11 +4,9 @@ After=network.target nss-lookup.target
[Service] [Service]
Type=simple Type=simple
WorkingDirectory=/usr/local/lib/hostsharing/hsadmin/qserv
Environment="PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin" Environment="PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin"
Environment="JAVA_OPTS=-Xbootclasspath/a:/etc/hsadmin/qserv/ -Djavax.net.ssl.keyStore=/etc/hsadmin/qserv/keystore -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/etc/hsadmin/qserv/truststore -Djavax.net.ssl.trustStorePassword=password -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*" Environment="JAVA_OPTS=-Xbootclasspath/a:/etc/hsadmin/qserv/ -Djavax.net.ssl.keyStore=/etc/hsadmin/qserv/keystore -Djavax.net.ssl.keyStorePassword=password -Djavax.net.ssl.trustStore=/etc/hsadmin/qserv/truststore -Djavax.net.ssl.trustStorePassword=password -Dorg.apache.activemq.SERIALIZABLE_PACKAGES=*"
ExecStartPre=/bin/bash /usr/local/lib/hostsharing/hsadmin/tools/init_hive_mysqldb.sh ExecStart=/usr/bin/java $JAVA_OPTS -jar /usr/local/lib/hostsharing/hsadmin/hsadmin-qserv-full.jar /etc/hsadmin/qserv/qserv.properties
ExecStart=/usr/bin/java $JAVA_OPTS -jar /usr/local/lib/hostsharing/hsadmin/hsadmin-qserv-full.jar
StandardOutput=file:/var/log/hostsharing/hsadmin/hsar-qserv.err StandardOutput=file:/var/log/hostsharing/hsadmin/hsar-qserv.err
StandardError=inherit StandardError=inherit
Restart=always Restart=always

2
qserv/.gitignore vendored
View File

@ -4,4 +4,4 @@
.classpath .classpath
.project .project
.settings/ .settings/
hsadmin.properties

14
qserv/hsadmin.properties Normal file
View File

@ -0,0 +1,14 @@
hsadmin.jms.url=ssl://hsh02.hostsharing.net:61617
hsadmin.jms.username=user-h98
hsadmin.jms.password=kein-echtes-ppasswort
hsadmin.jms.system-queue=queue.hsadminSystem-h98
hsadmin.jms.status-queue=queue.hsadminStatus
accountprefix.customer=hsh00
accountprefix.hostmaster=hsh01
queues.dns=testdns
queues.mail=testmail
hsadmin.smtp.from=nobody@hostsharing.net
hsadmin.smtp.cc=hostmaster@hostsharing.net
loginURL=TestUmgebung
backendURL=https://config.hostsharing.net:443/hsar/backend
xmlrpcURL=http://localhost:8080/hsar/xmlrpc/hsadmin

View File

@ -4,16 +4,16 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.hsadmin.core</groupId> <groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-qserv</artifactId> <artifactId>hsadmin-qserv</artifactId>
<version>4.0.18</version> <version>4.0.15</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version> <java.version>8</java.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>de.hsadmin.core</groupId> <groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-util</artifactId> <artifactId>hsadmin-util</artifactId>
<version>4.0.18</version> <version>4.0.15</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>commons-lang</groupId> <groupId>commons-lang</groupId>
@ -27,13 +27,13 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.velocity</groupId> <groupId>org.apache.velocity</groupId>
<artifactId>velocity-engine-core</artifactId> <artifactId>velocity</artifactId>
<version>2.3</version> <version>1.7</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.openjpa</groupId> <groupId>org.apache.openjpa</groupId>
<artifactId>openjpa</artifactId> <artifactId>openjpa</artifactId>
<version>3.2.2</version> <version>2.4.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
@ -43,8 +43,15 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId> <artifactId>activemq-all</artifactId>
<version>5.17.5</version> <version>5.5.0</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.geronimo.specs</groupId>
<artifactId>geronimo-jms_1.1_spec</artifactId>
<version>1.1.1</version>
<scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>
@ -54,14 +61,14 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version> <version>3.11.0</version>
<configuration> <configuration>
<source>11</source> <source>8</source>
<target>11</target> <target>8</target>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.openjpa</groupId> <groupId>org.apache.openjpa</groupId>
<artifactId>openjpa-maven-plugin</artifactId> <artifactId>openjpa-maven-plugin</artifactId>
<version>3.2.2</version> <version>2.4.3</version>
<configuration> <configuration>
<includes> <includes>
**/QueueTask.class,**/Domain.class,**/DomainOption.class,**/EMailAddress.class,**/EMailAlias.class,**/Customer.class,**/Contact.class,**/UnixUser.class,**/Pac.class,**/BasePac.class,**/BaseComponent.class,**/PacComponent.class,**/Component.class,**/Hive.class,**/INetAddress.class,**/Database.class,**/DatabaseUser.class,**/PgSqlDatabase.class,**/MySqlDatabase.class,**/PgSqlUser.class,**/MySqlUser.class **/QueueTask.class,**/Domain.class,**/DomainOption.class,**/EMailAddress.class,**/EMailAlias.class,**/Customer.class,**/Contact.class,**/UnixUser.class,**/Pac.class,**/BasePac.class,**/BaseComponent.class,**/PacComponent.class,**/Component.class,**/Hive.class,**/INetAddress.class,**/Database.class,**/DatabaseUser.class,**/PgSqlDatabase.class,**/MySqlDatabase.class,**/PgSqlUser.class,**/MySqlUser.class
@ -82,5 +89,40 @@
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>
<pluginManagement>
<plugins>
<!--This plugin's configuration is used to store Eclipse m2e settings only. It has no influence on the Maven build itself.-->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.openjpa
</groupId>
<artifactId>
openjpa-maven-plugin
</artifactId>
<versionRange>
[2.4.3,)
</versionRange>
<goals>
<goal>enhance</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build> </build>
</project> </project>

View File

@ -14,7 +14,6 @@ import de.hsadmin.core.qserv.EntityProcessorFactory;
import de.hsadmin.core.qserv.NullProcessor; import de.hsadmin.core.qserv.NullProcessor;
import de.hsadmin.core.qserv.Processor; import de.hsadmin.core.qserv.Processor;
import de.hsadmin.core.qserv.QueueTask; import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.qserv.TaskTransfer;
import de.hsadmin.core.util.HSAdminException; import de.hsadmin.core.util.HSAdminException;
import de.hsadmin.mods.user.UnixUser; import de.hsadmin.mods.user.UnixUser;
@ -200,10 +199,8 @@ public abstract class AbstractModuleImpl implements ModuleInterface {
StringBuilder details = new StringBuilder(); StringBuilder details = new StringBuilder();
String title = entityTypeName + " (" + entity.createStringKey() + ") " + action; String title = entityTypeName + " (" + entity.createStringKey() + ") " + action;
QueueTask task = new QueueTask(user, title, details.toString(), proc); QueueTask task = new QueueTask(user, title, details.toString(), proc);
final EntityManager entityManager = transaction.getEntityManager(); transaction.getEntityManager().persist(task);
entityManager.persist(task); transaction.enqueue(entity.getHiveName(), task);
entityManager.refresh(task);
transaction.enqueue(entity.getHiveName(), TaskTransfer.getTransferObject(task));
} }
public String toString(StackTraceElement[] stackTrace) { public String toString(StackTraceElement[] stackTrace) {

View File

@ -2,8 +2,6 @@ package de.hsadmin.core.model;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory; import javax.persistence.EntityManagerFactory;
@ -15,8 +13,6 @@ public class PersistenceManager {
private Map<String, EntityManagerFactory> persistenceUnits; private Map<String, EntityManagerFactory> persistenceUnits;
private Logger logger = Logger.getLogger(PersistenceManager.class.getName());
public static EntityManager getEntityManager(String persistUnitName) { public static EntityManager getEntityManager(String persistUnitName) {
EntityManagerFactory emf = PersistenceManager.getInstance().getEMF(persistUnitName); EntityManagerFactory emf = PersistenceManager.getInstance().getEMF(persistUnitName);
return emf.createEntityManager(); return emf.createEntityManager();
@ -35,7 +31,6 @@ public class PersistenceManager {
if (emf == null) { if (emf == null) {
emf = Persistence.createEntityManagerFactory(persistUnitName); emf = Persistence.createEntityManagerFactory(persistUnitName);
persistenceUnits.put(persistUnitName, emf); persistenceUnits.put(persistUnitName, emf);
logger.log(Level.INFO, "Create Persistence Unit: " + persistUnitName);
} }
return emf; return emf;
} }
@ -48,11 +43,11 @@ public class PersistenceManager {
} }
private void closeFactories() { private void closeFactories() {
for (String persistUnitName : persistenceUnits.keySet()) { for (String puName : persistenceUnits.keySet()) {
logger.log(Level.INFO, "Close Persistence Unit: " + persistUnitName); System.out.println("Persistence Unit: " + puName);
EntityManagerFactory emf = persistenceUnits.get(persistUnitName); EntityManagerFactory emf = persistenceUnits.get(puName);
emf.close(); emf.close();
persistenceUnits.remove(persistUnitName); persistenceUnits.remove(puName);
} }
} }
} }

View File

@ -6,20 +6,20 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import javax.jms.JMSException;
import javax.jms.Queue; import javax.jms.Queue;
import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory; import javax.jms.QueueConnectionFactory;
import javax.jms.QueueSession; import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.EntityManager; import javax.persistence.EntityManager;
import javax.persistence.EntityTransaction; import javax.persistence.EntityTransaction;
import javax.persistence.Query; import javax.persistence.Query;
import org.apache.activemq.ActiveMQConnectionFactory; //import org.apache.activemq.ActiveMQConnectionFactory;
import org.apache.openjpa.persistence.OpenJPAEntityManager; import org.apache.openjpa.persistence.OpenJPAEntityManager;
import de.hsadmin.core.qserv.QueueClient; import de.hsadmin.core.qserv.QueueClient;
import de.hsadmin.core.qserv.TaskTransfer; import de.hsadmin.core.qserv.QueueTask;
import de.hsadmin.core.util.Config; import de.hsadmin.core.util.Config;
import de.hsadmin.mods.cust.Customer; import de.hsadmin.mods.cust.Customer;
import de.hsadmin.mods.pac.Pac; import de.hsadmin.mods.pac.Pac;
@ -32,23 +32,24 @@ public class Transaction {
private String loginName; private String loginName;
private Map<String, QueueTaskStore> taskStores; private Map<String, QueueTaskStore> taskStores;
private boolean transactionActive; private boolean transactionActive;
private Config config; private InitialContext ctx;
private String jmsServerUrl;
private String jmsUsername;
private String jmsPassword;
public Transaction(String loginName) { public Transaction(String loginName) {
this.config = Config.getInstance();
this.jmsServerUrl = config.getProperty("hsadmin.jms.url", "tcp://localhost:61616");
this.jmsUsername = config.getProperty("hsadmin.jms.username", "hsar");
this.jmsPassword = config.getProperty("hsadmin.jms.password", "default");
this.transactionActive = false; this.transactionActive = false;
this.entityManager = PersistenceManager.getEntityManager("hsadmin"); this.entityManager = PersistenceManager.getEntityManager("hsadmin");
this.loginName = loginName; this.loginName = loginName;
this.taskStores = new HashMap<String, QueueTaskStore>(); this.taskStores = new HashMap<String, QueueTaskStore>();
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsServerUrl); try {
mqConnectionFactory.setTrustAllPackages(true); ctx = new InitialContext();
this.queueConnectionFactory = mqConnectionFactory; Context env = (Context) ctx.lookup("java:comp/env");
queueConnectionFactory = (QueueConnectionFactory) env.lookup("jms/QueueCF");
// if (queueConnectionFactory instanceof ActiveMQConnectionFactory) {
// ActiveMQConnectionFactory activeMQconnectionFatory = (ActiveMQConnectionFactory) queueConnectionFactory;
// activeMQconnectionFatory.setTrustAllPackages(true);
// }
} catch (NamingException e) {
throw new TechnicalException("no jms queue: jms/QueueCF", e);
}
} }
public EntityManager getEntityManager() { public EntityManager getEntityManager() {
@ -60,15 +61,16 @@ public class Transaction {
} }
public Queue lookupJMSQueue(String queueName) { public Queue lookupJMSQueue(String queueName) {
if (ctx != null) {
try { try {
final QueueConnection queueConnection = queueConnectionFactory.createQueueConnection(jmsUsername, jmsPassword); Context env = (Context) ctx.lookup("java:comp/env");
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); return (Queue) env.lookup("jms/" + queueName);
final Queue queue = session.createQueue(queueName); } catch (NamingException e) {
return queue;
} catch (JMSException e) {
throw new TechnicalException("no jms queue: jms/" + queueName, e); throw new TechnicalException("no jms queue: jms/" + queueName, e);
} }
} }
return null;
}
public String getLoginName() { public String getLoginName() {
if (loginName != null) { if (loginName != null) {
@ -77,7 +79,7 @@ public class Transaction {
throw new TechnicalException("no login"); throw new TechnicalException("no login");
} }
public void enqueue(String hiveName, TaskTransfer task) { public void enqueue(String hiveName, QueueTask task) {
QueueTaskStore taskStore = taskStores.get(hiveName); QueueTaskStore taskStore = taskStores.get(hiveName);
if (taskStore == null) { if (taskStore == null) {
taskStore = new QueueTaskStore(); taskStore = new QueueTaskStore();
@ -89,13 +91,13 @@ public class Transaction {
private void sendAll() { private void sendAll() {
for (String hive : taskStores.keySet()) { for (String hive : taskStores.keySet()) {
QueueTaskStore store = taskStores.get(hive); QueueTaskStore store = taskStores.get(hive);
String queueName = "queue.hsadminSystem-" + hive; String queueName = "hsadminSystem-" + hive;
Queue jmsSystemQueue = lookupJMSQueue(queueName); Queue jmsSystemQueue = lookupJMSQueue(queueName);
QueueClient qClient = null; QueueClient qClient = null;
try { try {
qClient = new QueueClient(queueConnectionFactory, jmsSystemQueue); qClient = new QueueClient(queueConnectionFactory, jmsSystemQueue);
for (TaskTransfer taskTransfer : store.getTasks()) { for (QueueTask task : store.getTasks()) {
qClient.send(taskTransfer); qClient.send(task);
} }
} catch (Exception e) { } catch (Exception e) {
throw new TechnicalException(e); throw new TechnicalException(e);
@ -145,13 +147,11 @@ public class Transaction {
if (transactionActive) { if (transactionActive) {
rollbackTransaction(); rollbackTransaction();
} }
if (entityManager != null) {
entityManager.close(); entityManager.close();
} }
}
/** /**
* Detach entities from JPA session. * Detach entities from hibernate session.
* Used to detach entities before update. Makes it possible to compare * Used to detach entities before update. Makes it possible to compare
* old and new attribute values. * old and new attribute values.
*/ */
@ -163,17 +163,17 @@ public class Transaction {
} }
class QueueTaskStore { class QueueTaskStore {
private List<TaskTransfer> taskList; private List<QueueTask> taskList;
QueueTaskStore() { QueueTaskStore() {
taskList = new ArrayList<TaskTransfer>(); taskList = new ArrayList<QueueTask>();
} }
public void clear() { public void clear() {
taskList = new ArrayList<TaskTransfer>(); taskList = new ArrayList<QueueTask>();
} }
void add(TaskTransfer t) { void add(QueueTask t) {
taskList.add(t); taskList.add(t);
} }
Iterable<TaskTransfer> getTasks() { Iterable<QueueTask> getTasks() {
return taskList; return taskList;
} }
} }
@ -181,10 +181,10 @@ public class Transaction {
public UnixUser getLoginUser() { public UnixUser getLoginUser() {
String loginName = getLoginName(); String loginName = getLoginName();
if (loginName != null && loginName.length() == 2) { if (loginName != null && loginName.length() == 2) {
loginName = config.getProperty("accountprefix.hostmaster", "hsh01") + "-" + loginName; loginName = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-" + loginName;
} }
if (loginName != null && loginName.length() == 3) { if (loginName != null && loginName.length() == 3) {
loginName = config.getProperty("accountprefix.customer", "hsh00") + "-" + loginName; loginName = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-" + loginName;
} }
Query userQuery = getEntityManager().createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username"); Query userQuery = getEntityManager().createQuery("SELECT u FROM UnixUsers u WHERE u.name = :username");
userQuery.setParameter("username", loginName); userQuery.setParameter("username", loginName);
@ -200,7 +200,7 @@ public class Transaction {
if (ticketUser != null && ticketUser.length() == 2) { if (ticketUser != null && ticketUser.length() == 2) {
return true; // 2-letter hostmaster return true; // 2-letter hostmaster
} }
String hostmasterAccountPrefix = config.getProperty("accountprefix.hostmaster", "hsh01") + "-"; String hostmasterAccountPrefix = Config.getInstance().getProperty("accountprefix.hostmaster", "hsh01") + "-";
if (ticketUser != null && ticketUser.startsWith(hostmasterAccountPrefix) && ticketUser.length() == 8) { if (ticketUser != null && ticketUser.startsWith(hostmasterAccountPrefix) && ticketUser.length() == 8) {
return true; // hsh01 hostmaster return true; // hsh01 hostmaster
} }
@ -211,7 +211,7 @@ public class Transaction {
String pacName = unixUser.getPac().getName(); String pacName = unixUser.getPac().getName();
return ticketUser.equals(pacName); // pac-admin return ticketUser.equals(pacName); // pac-admin
} }
String memberAccountPrefix = config.getProperty("accountprefix.customer", "hsh00") + "-"; String memberAccountPrefix = Config.getInstance().getProperty("accountprefix.customer", "hsh00") + "-";
if (ticketUser != null && (ticketUser.length() == 3 || (ticketUser.length() >= 9 && ticketUser.startsWith(memberAccountPrefix)))) { if (ticketUser != null && (ticketUser.length() == 3 || (ticketUser.length() >= 9 && ticketUser.startsWith(memberAccountPrefix)))) {
Query memberQuery = getEntityManager().createQuery("SELECT c FROM Customers c WHERE c.name = :membername"); Query memberQuery = getEntityManager().createQuery("SELECT c FROM Customers c WHERE c.name = :membername");
memberQuery.setParameter("membername", ticketUser.length() == 3 ? (memberAccountPrefix + ticketUser) : ticketUser); memberQuery.setParameter("membername", ticketUser.length() == 3 ? (memberAccountPrefix + ticketUser) : ticketUser);

View File

@ -14,9 +14,4 @@ abstract public class AbstractProcessor implements Processor {
task.done(); task.done();
} }
@Override
public String toString() {
return "a Processor of class " + this.getClass().getCanonicalName();
}
} }

View File

@ -57,7 +57,7 @@ public class JDBCProcessor extends AbstractProcessor {
throw new ProcessorException("cannot connect to '" + url + "'"); throw new ProcessorException("cannot connect to '" + url + "'");
Statement s = c.createStatement(); Statement s = c.createStatement();
for (String sqlStatement : sql) { for (String sqlStatement : sql) {
LOG.fine("SQL: " + sqlStatement); System.out.println("SQL: " + sqlStatement);
s.execute(sqlStatement); s.execute(sqlStatement);
} }
return 0; return 0;
@ -67,7 +67,7 @@ public class JDBCProcessor extends AbstractProcessor {
exc = aSqlExc; exc = aSqlExc;
} }
errorMsg = exc.getMessage(); errorMsg = exc.getMessage();
LOG.severe("ERR: " + errorMsg); System.out.println("ERR: " + errorMsg);
throw new ProcessorException(aSqlExc.getMessage() + ", reason: " + errorMsg); throw new ProcessorException(aSqlExc.getMessage() + ", reason: " + errorMsg);
} catch (Exception aExc) { } catch (Exception aExc) {
throw new ProcessorException(aExc.getMessage()); throw new ProcessorException(aExc.getMessage());

View File

@ -3,7 +3,7 @@ package de.hsadmin.core.qserv;
public class NullProcessor extends AbstractProcessor { public class NullProcessor extends AbstractProcessor {
private static final long serialVersionUID = -3667951484545665538L; private static final long serialVersionUID = 1L;
@Override @Override
public Object process() throws ProcessorException { public Object process() throws ProcessorException {

View File

@ -18,7 +18,7 @@ import de.hsadmin.core.util.Config;
* *
* @author mi * @author mi
*/ */
public class QueueClient { public class QueueClient extends QueueCommons {
private QueueConnectionFactory jmsConnectionFactory; private QueueConnectionFactory jmsConnectionFactory;
private Queue jmsSystemQueue; private Queue jmsSystemQueue;
@ -36,11 +36,11 @@ public class QueueClient {
String jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin"); String jmsUser = config.getProperty("hsadmin.jms.username", "hsadmin");
String jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw"); String jmsPass = config.getProperty("hsadmin.jms.password", "hsadmin-pw");
jmsConnection = jmsConnectionFactory.createQueueConnection(jmsUser, jmsPass); jmsConnection = jmsConnectionFactory.createQueueConnection(jmsUser, jmsPass);
jmsSession = jmsConnection.createQueueSession(false, Session.AUTO_ACKNOWLEDGE); jmsSession = jmsConnection.createQueueSession(DEFAULT, Session.AUTO_ACKNOWLEDGE);
jmsSender = jmsSession.createSender(jmsSystemQueue); jmsSender = jmsSession.createSender(jmsSystemQueue);
} }
public void send(TaskTransfer task) throws ProcessorException { public void send(QueueTask task) throws ProcessorException {
try { try {
ObjectMessage jmsMessage = jmsSession.createObjectMessage(task); ObjectMessage jmsMessage = jmsSession.createObjectMessage(task);
jmsSender.send(jmsMessage); jmsSender.send(jmsMessage);
@ -55,7 +55,7 @@ public class QueueClient {
} }
} }
private String queueName(Queue jmsSystemQueue) { private String queueName(Queue jmsSystemQueue2) {
try { try {
return jmsSystemQueue.getQueueName(); return jmsSystemQueue.getQueueName();
} catch (Exception exc) { } catch (Exception exc) {

View File

@ -0,0 +1,14 @@
package de.hsadmin.core.qserv;
public class QueueCommons
{
protected static final boolean TRANSACTED = true;
protected static final boolean IMMEDIATE = false;
protected static final boolean DEFAULT = IMMEDIATE;
public QueueCommons()
{
super();
}
}

View File

@ -1,8 +1,14 @@
package de.hsadmin.core.qserv; package de.hsadmin.core.qserv;
import java.io.File;
import java.io.FileInputStream;
import java.util.Properties;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.jms.Connection;
import javax.jms.ConnectionFactory;
import javax.jms.Destination;
import javax.jms.ExceptionListener; import javax.jms.ExceptionListener;
import javax.jms.JMSException; import javax.jms.JMSException;
import javax.jms.Message; import javax.jms.Message;
@ -11,82 +17,90 @@ import javax.jms.MessageProducer;
import javax.jms.ObjectMessage; import javax.jms.ObjectMessage;
import javax.jms.Queue; import javax.jms.Queue;
import javax.jms.QueueConnection; import javax.jms.QueueConnection;
import javax.jms.QueueConnectionFactory;
import javax.jms.QueueReceiver; import javax.jms.QueueReceiver;
import javax.jms.QueueSession; import javax.jms.QueueSession;
import javax.jms.Session;
import javax.naming.Context;
import javax.naming.InitialContext;
import org.apache.activemq.ActiveMQConnectionFactory; public class QueueServer extends QueueCommons implements MessageListener, ExceptionListener {
import de.hsadmin.core.util.Config; private static final String VERSION_NO = "4.0.11";
public class QueueServer implements MessageListener, ExceptionListener {
private static final String VERSION_NO = "4.0.16";
private Logger logger; private Logger logger;
private QueueConnection conn;
private String jmsUrl; private QueueSession queueSession;
private String jmsUsername;
private String jmsPassword;
private String jmsSystemQueue;
private String jmsStatusQueue; private String jmsStatusQueue;
private String jmsPassWord;
private String jmsUserName;
private String jmsSystemQueue;
private String jmsFactory;
private String serviceEMail; private String serviceEMail;
private String fromEMail; private String fromEMail;
private QueueConnection queueConnection;
private boolean isConnected;
/** /**
* Runs the QueueServer. * Runs the QueueServer, using the arguments as ConnectionFactory
* and Topic names.
*/ */
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
final Config config = Config.getInstance(); File propFile = new File(System.getProperty("user.dir"), "conf/qserv.properties");
System.setProperty("java.util.logging.config.file", config.getProperty("hsadmin.log.config", System.getProperty("user.home") + "/.hsadmin.log.properties")); if (args.length == 1) {
propFile = new File(args[0]);
} else {
if (args.length != 0) {
throw new Exception(userHelp(propFile));
}
}
FileInputStream propStream = new FileInputStream(propFile);
Properties props = new Properties(System.getProperties());
props.load(propStream);
propStream.close();
System.setProperty("java.util.logging.config.file", props.getProperty("hsadmin.log.config", System.getProperty("user.home") + "/.hsadmin.log.properties"));
final QueueServer qServ = new QueueServer(); final QueueServer qServ = new QueueServer();
qServ.setJmsURL(config.getProperty("hsadmin.jms.url")); qServ.setJmsFactory(props.getProperty("hsadmin.jms.factory"));
qServ.setJmsSystemQueue(config.getProperty("hsadmin.jms.system-queue")); qServ.setJmsSystemQueue(props.getProperty("hsadmin.jms.system-queue"));
qServ.setJmsStatusQueue(config.getProperty("hsadmin.jms.status-queue")); qServ.setJmsStatusQueue(props.getProperty("hsadmin.jms.status-queue"));
qServ.setJmsUserName(config.getProperty("hsadmin.jms.username")); qServ.setJmsUserName(props.getProperty("hsadmin.jms.username"));
qServ.setJmsPassWord(config.getProperty("hsadmin.jms.password")); qServ.setJmsPassWord(props.getProperty("hsadmin.jms.password"));
qServ.setServiceEMail(config.getProperty("hsadmin.log.email")); qServ.setServiceEMail(props.getProperty("hsadmin.log.email"));
qServ.setFromEMail(config.getProperty("hsadmin.log.from")); qServ.setFromEMail(props.getProperty("hsadmin.log.from"));
Logger logger = Logger.getLogger("de.hsadmin.core.qserv"); Logger logger = Logger.getLogger("de.hsadmin.core.qserv");
logger.log(Level.CONFIG, "hsadmin-qserv " + VERSION_NO + " started using:" logger.log(Level.CONFIG, "hsadmin-qserv " + VERSION_NO + " started using:"
+ "\nsystem queue: " + config.getProperty("hsadmin.jms.system-queue") + "\nqueue server: " + props.getProperty("hsadmin.jms.factory")
+ "\nstatus queue: " + config.getProperty("hsadmin.jms.status-queue") + "\nsystem queue: " + props.getProperty("hsadmin.jms.system-queue")
+ "\nqueue user: " + config.getProperty("hsadmin.jms.username")); + "\nstatus queue: " + props.getProperty("hsadmin.jms.status-queue")
+ "\nqueue user: " + props.getProperty("hsadmin.jms.username"));
Runtime.getRuntime().addShutdownHook(new Thread() { Runtime.getRuntime().addShutdownHook(new Thread() {
@Override @Override
public void run() { public void run() {
qServ.close(); qServ.close();
} }
}); });
while (true) { while (!qServ.connect()) {
if (!qServ.isConnected()) { Thread.sleep(10000);
qServ.connect();
} }
Thread.sleep(30000); while (true) {
Thread.sleep(10000);
} }
} }
protected void close() { private static String userHelp(File propFile) {
if (queueConnection != null) { return "Wrong number of arguments.\n"
try { + "With no arguments '"
queueConnection.close(); + propFile
} catch (JMSException e) { + "' will be used as config file.\n"
logger.log(Level.SEVERE, e.getMessage()); + "Or give a properties file as single argument.\n\n"
} + "Example config file:\n\n"
} + "hsadmin.jms.factory=QueueCF\n"
+ "hsadmin.jms.system-queue=hive-h01\n"
+ "hsadmin.jms.status-queue=queue/hsadminStatus\n"
+ "hsadmin.jms.username=hive-h01\n"
+ "hsadmin.jms.password=geheimeskennwort\n";
} }
public QueueServer() { public QueueServer() {
logger = Logger.getLogger("de.hsadmin.core.qserv"); logger = Logger.getLogger("de.hsadmin.core.qserv");
queueConnection = null;
isConnected = false;
}
private boolean isConnected() {
return isConnected;
} }
private void setServiceEMail(String emailAddress) { private void setServiceEMail(String emailAddress) {
@ -105,31 +119,32 @@ public class QueueServer implements MessageListener, ExceptionListener {
} }
} }
private void connect() { private boolean connect() {
// create JMS connection and session
try { try {
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl); Context ctx = new InitialContext();
mqConnectionFactory.setTrustAllPackages(true); QueueConnectionFactory connectionFactory =
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword); (QueueConnectionFactory) ctx.lookup(jmsFactory);
queueConnection.setExceptionListener(this); conn = connectionFactory.createQueueConnection(jmsUserName, jmsPassWord);
final QueueSession session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); conn.setExceptionListener(this);
Queue queue = session.createQueue(jmsSystemQueue); queueSession = conn.createQueueSession(false, Session.AUTO_ACKNOWLEDGE);
queueConnection.start(); Queue queue = (Queue) ctx.lookup(jmsSystemQueue);
final QueueReceiver receiver = session.createReceiver(queue); conn.start();
QueueReceiver receiver = queueSession.createReceiver(queue);
receiver.setMessageListener(this); receiver.setMessageListener(this);
isConnected = true; return true;
} catch (Exception e) { } catch (Exception e) {
logger.log(Level.WARNING, e.getMessage(), e); logger.log(Level.WARNING, e.getMessage(), e);
isConnected = false; return false;
} }
} }
public synchronized void onMessage(final Message jmsMessage) { public synchronized void onMessage(Message jmsMessage) {
assert jmsMessage != null;
logger.log(Level.INFO, jmsMessage.toString()); logger.log(Level.INFO, jmsMessage.toString());
TaskTransfer task = null; QueueTask task = null;
try { try {
ObjectMessage jmsObjectMessage = (ObjectMessage) jmsMessage; ObjectMessage jmsObjectMessage = (ObjectMessage) jmsMessage;
task = (TaskTransfer) jmsObjectMessage.getObject(); task = (QueueTask) jmsObjectMessage.getObject();
Processor processor = task.getProcessor(); Processor processor = task.getProcessor();
logger.log(Level.INFO, "processing (" + task.getTitle() + " | started(" logger.log(Level.INFO, "processing (" + task.getTitle() + " | started("
+ task.getStarted() + ") |" + task.getDetails() + "|" + task.getStarted() + ") |" + task.getDetails() + "|"
@ -139,12 +154,12 @@ public class QueueServer implements MessageListener, ExceptionListener {
logger.log(Level.INFO, "done"); logger.log(Level.INFO, "done");
} catch (ProcessorException e) { } catch (ProcessorException e) {
logException(e); logException(e);
task.setException(e.getMessage()); task.setException(e);
SmtpHelper.send(fromEMail, serviceEMail, jmsSystemQueue, processor.logInfo()); SmtpHelper.send(fromEMail, serviceEMail, jmsSystemQueue, processor.logInfo());
} }
} catch (Throwable throwable) { } catch (Throwable throwable) {
logException(throwable); logException(throwable);
task.setException(throwable.getMessage()); task.setException(throwable);
} finally { } finally {
sendStatus(task); sendStatus(task);
notifyAll(); notifyAll();
@ -163,53 +178,70 @@ public class QueueServer implements MessageListener, ExceptionListener {
public void onException(JMSException e) { public void onException(JMSException e) {
logger.log(Level.WARNING, e.getMessage(), e); logger.log(Level.WARNING, e.getMessage(), e);
close(); close();
isConnected = false; while (!connect()) {
try {
Thread.sleep(10000);
} catch (InterruptedException e1) { }
}
} }
protected void sendStatus(TaskTransfer queueMessage) { public void close() {
final ActiveMQConnectionFactory mqConnectionFactory = new ActiveMQConnectionFactory(jmsUrl); if (queueSession != null) {
mqConnectionFactory.setTrustAllPackages(true);
QueueConnection queueConnection = null;
MessageProducer producer = null;
QueueSession session = null;
try { try {
queueConnection = mqConnectionFactory.createQueueConnection(jmsUsername, jmsPassword); queueSession.close();
queueConnection.setExceptionListener(this); } catch (JMSException e1) { }
session = queueConnection.createQueueSession(false, QueueSession.AUTO_ACKNOWLEDGE); }
final Queue queue = session.createQueue(jmsStatusQueue); if (conn != null) {
queueConnection.start(); try {
producer = session.createProducer(queue); conn.close();
final ObjectMessage statusMessage = session.createObjectMessage(queueMessage); } catch (JMSException e1) { }
producer.send(statusMessage); }
}
protected void sendStatus(QueueTask queueMessage) {
MessageProducer producer = null;
Session statusSession = null;
Connection statusConnection = null;
try {
logger.log(Level.INFO, "sendStatus(" + queueMessage + ")");
Context ctx = new InitialContext();
ConnectionFactory connectionFactory = (ConnectionFactory) ctx.lookup(jmsFactory);
Destination queue = (Destination) ctx.lookup(jmsStatusQueue);
statusConnection = connectionFactory.createConnection(jmsUserName, jmsPassWord);
statusSession = statusConnection.createSession(false, Session.AUTO_ACKNOWLEDGE);
producer = statusSession.createProducer(queue);
ObjectMessage statusMessage = statusSession.createObjectMessage(queueMessage);
logger.log(Level.INFO, "send(" + statusMessage + ")"); logger.log(Level.INFO, "send(" + statusMessage + ")");
producer.send(statusMessage);
} catch (Exception statusException) { } catch (Exception statusException) {
logger.log(Level.SEVERE, statusException.getMessage(), statusException); logger.log(Level.SEVERE, statusException.getMessage(), statusException);
} finally { } finally {
if (producer != null) try { producer.close(); } catch (Exception e) { } // close JMS
if (session != null) try { session.close(); } catch (Exception e) { } try { producer.close(); } catch (Exception exc) { }
if (queueConnection != null) try { queueConnection.close(); } catch (Exception e) { } try { statusSession.close(); } catch (Exception exc) { }
try { statusConnection.close(); } catch (Exception exc) { }
} }
} }
private void setJmsURL(String property) {
jmsUrl = property;
}
public void setJmsPassWord(String property) {
jmsPassword = property;
}
public void setJmsUserName(String property) {
jmsUsername = property;
}
public void setJmsSystemQueue(String property) {
jmsSystemQueue = property;
}
public void setJmsStatusQueue(String property) { public void setJmsStatusQueue(String property) {
jmsStatusQueue = property; jmsStatusQueue = property;
} }
public void setJmsPassWord(String property) {
jmsPassWord = property;
}
public void setJmsUserName(String property) {
jmsUserName = property;
}
public void setJmsSystemQueue(String property) {
jmsSystemQueue = property;
}
public void setJmsFactory(String property) {
jmsFactory = property;
}
} }

View File

@ -223,13 +223,14 @@ public class QueueTask extends AbstractEntity implements Serializable {
* assigns all data field of qt to this instance, with * assigns all data field of qt to this instance, with
* the exception of the id * the exception of the id
*/ */
public void assign(TaskTransfer qt) { public void assign(QueueTask qt) {
this.title = qt.getTitle(); this.user = qt.user;
this.details = qt.getDetails(); this.title = qt.title;
this.started = qt.getStarted(); this.details = qt.details;
this.finished = qt.getFinished(); this.started = qt.started;
this.proc = qt.getProcessor(); this.finished = qt.finished;
this.exception = qt.getException(); this.proc = qt.proc;
this.exception = qt.exception;
} }
@Override @Override

View File

@ -8,7 +8,7 @@ package de.hsadmin.core.qserv;
*/ */
public class ShellProcessor extends AbstractProcessor { public class ShellProcessor extends AbstractProcessor {
private static final long serialVersionUID = -8340381162948081669L; private static final long serialVersionUID = 1L;
private String aSystemCall; private String aSystemCall;
private String aInput; private String aInput;

View File

@ -6,7 +6,6 @@ import java.io.Writer;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.SocketException; import java.net.SocketException;
import java.net.UnknownHostException; import java.net.UnknownHostException;
import java.util.logging.Logger;
import org.apache.commons.net.smtp.SMTPClient; import org.apache.commons.net.smtp.SMTPClient;
import org.apache.commons.net.smtp.SMTPReply; import org.apache.commons.net.smtp.SMTPReply;
@ -17,8 +16,6 @@ import de.hsadmin.core.util.HSAdminException;
public class SmtpHelper { public class SmtpHelper {
private static final Logger LOG = Logger.getLogger(SmtpHelper.class.getName());
public static void send(String fromAddress, String toAddress, String subject, String text) public static void send(String fromAddress, String toAddress, String subject, String text)
throws HSAdminException { throws HSAdminException {
send(fromAddress, toAddress, null, subject, text); send(fromAddress, toAddress, null, subject, text);
@ -27,10 +24,9 @@ public class SmtpHelper {
public static void send(String fromAddress, String toAddress, String ccAddress, String subject, String text) public static void send(String fromAddress, String toAddress, String ccAddress, String subject, String text)
throws HSAdminException { throws HSAdminException {
try { try {
final SMTPClient client = new SMTPClient(); SMTPClient client = new SMTPClient();
String canonicalHostName = InetAddress.getLocalHost().getCanonicalHostName(); String canonicalHostName = InetAddress.getLocalHost().getCanonicalHostName();
final Config config = Config.getInstance(); String smtpHost = Config.getInstance().getProperty("smtp.host");
String smtpHost = config.getProperty("smtp.host");
if (smtpHost == null || smtpHost.trim().isEmpty()) { if (smtpHost == null || smtpHost.trim().isEmpty()) {
smtpHost = "localhost"; smtpHost = "localhost";
} }
@ -38,10 +34,11 @@ public class SmtpHelper {
if (subject.toLowerCase().contains("error")) { if (subject.toLowerCase().contains("error")) {
throw new HSAdminException("Konnte Mail nicht senden"); throw new HSAdminException("Konnte Mail nicht senden");
} }
LOG.finer("From: " + fromAddress); System.out.println("------------------------");
LOG.finer("To: " + toAddress); System.out.println("From: " + fromAddress);
LOG.finer("Subject: " + subject); System.out.println("To: " + toAddress);
LOG.finer(text); System.out.println("Subject: " + subject);
System.out.println("\n" + text);
return; return;
} }
client.connect(smtpHost, 25); client.connect(smtpHost, 25);

View File

@ -1,130 +0,0 @@
package de.hsadmin.core.qserv;
import java.io.Serializable;
import java.util.Date;
import de.hsadmin.mods.user.UnixUser;
public class TaskTransfer implements Serializable {
private static final long serialVersionUID = -2120247737335542484L;
private long id;
private String unixuser;
private Date started;
private Date finished;
private String title;
private String details;
private Processor proc;
private String exception;
public TaskTransfer() {
id = 0L;
unixuser = "anonymous";
started = new Date();
finished = null;
title = "untitled";
details = "none";
setProcessor(new NullProcessor());
setException("");
}
public TaskTransfer(long id, String unixuser, Date started, Date finished, String title, String details, Processor proc, String exception) {
this.id = id;
this.unixuser = unixuser;
this.started = started;
this.finished = finished;
this.title = title;
this.details = details;
this.setProcessor(proc);
this.setException(exception);
}
public long getId() {
return id;
}
public void setId(long id) {
this.id = id;
}
public String getUnixuser() {
return unixuser;
}
public void setUnixuser(String unixuser) {
this.unixuser = unixuser;
}
public Date getStarted() {
return started;
}
public void setStarted(Date started) {
this.started = started;
}
public Date getFinished() {
return finished;
}
public void setFinished(Date finished) {
this.finished = finished;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDetails() {
return details;
}
public void setDetails(String details) {
this.details = details;
}
public Processor getProcessor() {
return proc;
}
public void setProcessor(Processor proc) {
this.proc = proc;
}
public String getException() {
return exception;
}
public void setException(String exception) {
this.exception = exception;
}
@Override
public String toString() {
return Long.toString(id) + "|" + title + "|" + started.toString();
}
public static TaskTransfer getTransferObject(QueueTask task) {
long id = task.getId();
final UnixUser user = task.getUser();
String username = "anonymous";
if (user == null) {
username = "anonymous";
} else {
username = user.getName();
}
Date started = task.getStarted();
Date finished = task.getFinished();
String title = task.getTitle();
String details = task.getDetails();
Processor proc = task.getProcessor();
String exception = task.getException();
return new TaskTransfer(id, username, started, finished, title, details, proc, exception);
}
}

View File

@ -4,8 +4,6 @@ import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.EntityManager;
import de.hsadmin.core.model.Transaction; import de.hsadmin.core.model.Transaction;
public class WaitingTasksProcessor extends AbstractProcessor { public class WaitingTasksProcessor extends AbstractProcessor {
@ -31,10 +29,8 @@ public class WaitingTasksProcessor extends AbstractProcessor {
for (WaitingProcessor p : waitingTasks) { for (WaitingProcessor p : waitingTasks) {
QueueTask wTask = QueueTask wTask =
new QueueTask(task.getUser(), task.getTitle() + " / " + p.getTitle(), task.getTitle() + " / " + p.getTitle(), p.getProc()); new QueueTask(task.getUser(), task.getTitle() + " / " + p.getTitle(), task.getTitle() + " / " + p.getTitle(), p.getProc());
final EntityManager entityManager = transaction.getEntityManager(); transaction.getEntityManager().persist(wTask);
entityManager.persist(wTask); transaction.enqueue(p.getHost(), wTask);
entityManager.refresh(wTask);
transaction.enqueue(p.getHost(), TaskTransfer.getTransferObject(wTask));
} }
} }
super.finalize(transaction, task); super.finalize(transaction, task);

View File

@ -55,6 +55,10 @@ public class Domain extends AbstractEntity {
@Column(name = "domain_dns_master", columnDefinition = "character varying(64)") @Column(name = "domain_dns_master", columnDefinition = "character varying(64)")
private String dnsMaster; private String dnsMaster;
@AnnFieldIO(validation="([a-z0-9\\-]+\\,)*[a-z0-9\\-]+|\\*|", rw=ReadWriteAccess.READWRITE)
@Column(name = "valid_subdomain_names", columnDefinition = "character varying(512)")
private String validsubdomainnames;
@AnnFieldIO(validation="[a-zA-Z0-9\\-\\.]*", rw=ReadWriteAccess.READWRITE, referTo=DomainOption.class, selectableValues=DomainOptionValues.class) @AnnFieldIO(validation="[a-zA-Z0-9\\-\\.]*", rw=ReadWriteAccess.READWRITE, referTo=DomainOption.class, selectableValues=DomainOptionValues.class)
@ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST) @ManyToMany(fetch=FetchType.EAGER, cascade=CascadeType.PERSIST)
@JoinTable(name="domain__domain_option", @JoinTable(name="domain__domain_option",
@ -62,9 +66,21 @@ public class Domain extends AbstractEntity {
inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")}) inverseJoinColumns={@JoinColumn(name="domain_option_id", referencedColumnName="domain_option_id")})
private Set<DomainOption> domainoptions; private Set<DomainOption> domainoptions;
@AnnFieldIO(validation="([a-z0-9\\-]+\\,)*[a-z0-9\\-]+|\\*|", rw=ReadWriteAccess.READWRITE) @AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE)
@Column(name = "valid_subdomain_names", columnDefinition = "character varying(512)") @Column(name = "passenger_python", columnDefinition = "character varying(256)")
private String validsubdomainnames; private String passengerpython;
@AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE)
@Column(name = "passenger_nodejs", columnDefinition = "character varying(256)")
private String passengernodejs;
@AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE)
@Column(name = "passenger_ruby", columnDefinition = "character varying(256)")
private String passengerruby;
@AnnFieldIO(validation="[a-zA-Z0-9\\_\\-\\/\\.]*", rw=ReadWriteAccess.READWRITE)
@Column(name = "fcgi_php_bin", columnDefinition = "character varying(256)")
private String fcgiphpbin;
public Domain() { public Domain() {
} }
@ -175,6 +191,14 @@ public class Domain extends AbstractEntity {
"obj.user=:loginUser"; "obj.user=:loginUser";
} }
public String getValidsubdomainnames() {
return validsubdomainnames;
}
public void setValidsubdomainnames(String validSubdomainNames) {
this.validsubdomainnames = validSubdomainNames;
}
public Set<DomainOption> getDomainoptions() { public Set<DomainOption> getDomainoptions() {
return domainoptions; return domainoptions;
} }
@ -183,12 +207,48 @@ public class Domain extends AbstractEntity {
this.domainoptions = domainOptions; this.domainoptions = domainOptions;
} }
public String getValidsubdomainnames() { public String getPassengerpython() {
return validsubdomainnames; if (passengerpython == null) {
return "/usr/bin/python3";
}
return passengerpython;
} }
public void setValidsubdomainnames(String validSubdomainNames) { public void setPassengerpython(String value) {
this.validsubdomainnames = validSubdomainNames; this.passengerpython = value;
}
public String getPassengernodejs() {
if (passengernodejs == null) {
return "/usr/bin/node";
}
return passengernodejs;
}
public void setPassengernodejs(String value) {
this.passengernodejs = value;
}
public String getPassengerruby() {
if (passengerruby == null) {
return "/usr/bin/ruby";
}
return passengerruby;
}
public void setPassengerruby(String value) {
this.passengerruby = value;
}
public String getFcgiphpbin() {
if (fcgiphpbin == null) {
return "/usr/lib/cgi-bin/php";
}
return fcgiphpbin;
}
public void setFcgiphpbin(String value) {
this.fcgiphpbin = value;
} }
public String getServeraliases() { public String getServeraliases() {

View File

@ -30,6 +30,10 @@ public class DomainModuleImpl extends AbstractModuleImpl {
public static final String DOMOPT_LETSENCRYPT = "letsencrypt"; public static final String DOMOPT_LETSENCRYPT = "letsencrypt";
public static final String DOMOPT_AUTOCONFIG = "autoconfig"; public static final String DOMOPT_AUTOCONFIG = "autoconfig";
public static final String DOMOPT_DKIM = "dkim"; public static final String DOMOPT_DKIM = "dkim";
public static final String DOMOPT_PASSENGER = "passenger";
public static final String DOMOPT_PASSENGERFRIENDLYERRORPAGES = "passengerfriendlyerrorpages";
public static final String DOMOPT_CGI = "cgi";
public static final String DOMOPT_FASTCGI = "fastcgi";
public static final String[] ALL_DOMOPTS = public static final String[] ALL_DOMOPTS =
new String[] { new String[] {
@ -41,18 +45,21 @@ public class DomainModuleImpl extends AbstractModuleImpl {
DOMOPT_BACKUPFOREXTERNALMX, DOMOPT_BACKUPFOREXTERNALMX,
DOMOPT_LETSENCRYPT, DOMOPT_LETSENCRYPT,
DOMOPT_AUTOCONFIG, DOMOPT_AUTOCONFIG,
DOMOPT_DKIM DOMOPT_DKIM,
DOMOPT_PASSENGER,
DOMOPT_PASSENGERFRIENDLYERRORPAGES,
DOMOPT_CGI,
DOMOPT_FASTCGI
}; };
public static final String[] DEFAULT_DOMOPTS = public static final String[] DEFAULT_DOMOPTS =
new String[] { new String[] {
DOMOPT_GREYLISTING, DOMOPT_GREYLISTING,
DOMOPT_MULTIVIEWS,
DOMOPT_INDEXES, DOMOPT_INDEXES,
DOMOPT_HTDOCSFALLBACK, DOMOPT_HTDOCSFALLBACK,
DOMOPT_INCLUDES,
DOMOPT_LETSENCRYPT, DOMOPT_LETSENCRYPT,
DOMOPT_AUTOCONFIG, DOMOPT_AUTOCONFIG,
DOMOPT_DKIM DOMOPT_DKIM,
DOMOPT_FASTCGI
}; };
@Override @Override

View File

@ -27,6 +27,10 @@ public class DomainOptionValues extends DefaultSelectableValues {
list.add(new BooleanListValue("letsencrypt")); list.add(new BooleanListValue("letsencrypt"));
list.add(new BooleanListValue("autoconfig")); list.add(new BooleanListValue("autoconfig"));
list.add(new BooleanListValue("dkim")); list.add(new BooleanListValue("dkim"));
list.add(new BooleanListValue("passenger"));
list.add(new BooleanListValue("passengerfriendlyerrorpages"));
list.add(new BooleanListValue("cgi"));
list.add(new BooleanListValue("fastcgi"));
return list; return list;
} }

View File

@ -106,7 +106,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm", new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
templateVars, "/etc/bind/named-hsh.conf.tmp", true), 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 ) " + 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 )") "|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && systemctl reload bind9.service )")
); );
} }
@ -173,7 +173,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm", new VelocityProcessor("/de/hsadmin/mods/dom/postgrey-whitelist-recipients.vm",
templateVars, "/etc/postgrey/whitelist_recipients.tmp", true), templateVars, "/etc/postgrey/whitelist_recipients.tmp", true),
new ShellProcessor(" ( diff -q /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && rm /etc/postgrey/whitelist_recipients.tmp ) " + new ShellProcessor(" ( diff -q /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && rm /etc/postgrey/whitelist_recipients.tmp ) " +
"|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && invoke-rc.d postgrey reload )") "|| ( mv /etc/postgrey/whitelist_recipients.tmp /etc/postgrey/whitelist_recipients && systemctl restart postgrey.service )")
); );
} }
@ -237,10 +237,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false) new CreateFileProcessor("/de/hsadmin/mods/dom/index.html.vm", templateVars, dom, domainDir + "/subs-ssl/www/index.html", userName, pacName, "644", false)
); );
domDirsProcessor.appendProcessor( domDirsProcessor.appendProcessor(
new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi/phpstub", userName, pacName, "755") new CopyFileProcessor("/usr/local/src/phpstub/hs-phpstub", domainDir + "/fastcgi/hs-phpstub", userName, pacName, "755")
); );
domDirsProcessor.appendProcessor( domDirsProcessor.appendProcessor(
new CopyFileProcessor("/usr/local/src/phpstub/phpstub", domainDir + "/fastcgi-ssl/phpstub", userName, pacName, "755") new CopyFileProcessor("/usr/local/src/phpstub/hs-phpstub", domainDir + "/fastcgi-ssl/hs-phpstub", userName, pacName, "755")
);
domDirsProcessor.appendProcessor(
new ShellProcessor("chattr +i " + domainDir + "/fastcgi/hs-phpstub && " +
"chattr +i " + domainDir + "/fastcgi-ssl/hs-phpstub")
); );
domDirsProcessor.appendProcessor( domDirsProcessor.appendProcessor(
new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " + new ShellProcessor("ln -sf " + domainDir + " /home/doms/ && " +
@ -263,6 +267,14 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
ifOption(templateVars, query, "htdocsfallback", Boolean.TRUE, Boolean.FALSE); ifOption(templateVars, query, "htdocsfallback", Boolean.TRUE, Boolean.FALSE);
ifOption(templateVars, query, "letsencrypt", Boolean.TRUE, Boolean.FALSE); ifOption(templateVars, query, "letsencrypt", Boolean.TRUE, Boolean.FALSE);
ifOption(templateVars, query, "autoconfig", Boolean.TRUE, Boolean.FALSE); ifOption(templateVars, query, "autoconfig", Boolean.TRUE, Boolean.FALSE);
ifOption(templateVars, query, "passenger", Boolean.TRUE, Boolean.FALSE);
ifOption(templateVars, query, "passengerfriendlyerrorpages", Boolean.TRUE, Boolean.FALSE);
ifOption(templateVars, query, "cgi", Boolean.TRUE, Boolean.FALSE);
ifOption(templateVars, query, "fastcgi", Boolean.TRUE, Boolean.FALSE);
setPathInTemplate(templateVars, "passengerpython", "/usr/bin/python3", dom.getPassengerpython());
setPathInTemplate(templateVars, "passengernodejs", "/usr/bin/node", dom.getPassengernodejs());
setPathInTemplate(templateVars, "passengerruby", "/usr/bin/ruby", dom.getPassengerruby());
setPathInTemplate(templateVars, "fcgiphpbin", "/usr/lib/cgi-bin/php", dom.getFcgiphpbin());
final boolean isSetLetsencryptOption = templateVars.get("letsencrypt").equals(Boolean.TRUE); final boolean isSetLetsencryptOption = templateVars.get("letsencrypt").equals(Boolean.TRUE);
final Processor domSetupProcessor = new CompoundProcessor( final Processor domSetupProcessor = new CompoundProcessor(
isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"), isSetLetsencryptOption ? new NullProcessor() : new ShellProcessor("rm -f /etc/apache2/pems-generated/" + domName + ".crt"),
@ -287,11 +299,19 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
" || (mv /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName + " || (mv /etc/apache2/sites-available/" + domName + ".tmp /etc/apache2/sites-available/" + domName +
" && rm -f /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName + " && rm -f /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
" && ln -sf /etc/apache2/sites-available/" + domName + " /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName + " && ln -sf /etc/apache2/sites-available/" + domName + " /etc/apache2/sites-enabled/" + linkPrefix + "-" + domName +
" && invoke-rc.d apache2 reload >/dev/null 2>&1)") " && systemctl reload apache2.service >/dev/null 2>&1)")
); );
return domSetupProcessor; return domSetupProcessor;
} }
private void setPathInTemplate(final Map<String, Object> templateVars, final String templateVariable, final String defaultPath, final String actualPath) {
String pathVariable = actualPath;
if (pathVariable == null || pathVariable.isEmpty()) {
pathVariable = defaultPath;
}
templateVars.put(templateVariable, pathVariable);
}
private void ifOption(Map<String, Object> templateVars, Query query, String option, Object optIsTrue, Object optIsFalse) { private void ifOption(Map<String, Object> templateVars, Query query, String option, Object optIsTrue, Object optIsFalse) {
query.setParameter("option", option); query.setParameter("option", option);
if (query.getResultList().isEmpty()) { if (query.getResultList().isEmpty()) {
@ -320,8 +340,7 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
" && mkdir " + homedir + "/doms.bak" + " && mkdir " + homedir + "/doms.bak" +
" && mv " + homedir + "/doms/" + domname + " " + homedir + "/doms.bak/" + " && mv " + homedir + "/doms/" + domname + " " + homedir + "/doms.bak/" +
" && chown -R " + username + ":" + username + " " + homedir + "/doms.bak" + " && chown -R " + username + ":" + username + " " + homedir + "/doms.bak" +
// " && salt-call state.sls pacs " + " && systemctl reload apache2.service >/dev/null 2>&1");
" && invoke-rc.d apache2 reload >/dev/null 2>&1");
} }
return return
new ShellProcessor("rm -f /home/doms/" + domname + new ShellProcessor("rm -f /home/doms/" + domname +
@ -333,8 +352,10 @@ public class DomainProcessorFactory implements EntityProcessorFactory {
" && rm -f /etc/apache2/pems-generated/" + domname + ".crt" + " && rm -f /etc/apache2/pems-generated/" + domname + ".crt" +
" && rm -f /etc/apache2/pems-generated/" + domname + ".key" + " && rm -f /etc/apache2/pems-generated/" + domname + ".key" +
" && rm -f /etc/apache2/pems-generated/" + domname + ".chain" + " && rm -f /etc/apache2/pems-generated/" + domname + ".chain" +
" && chattr -i " + homedir + "/doms/" + domname + "/fastcgi/hs-phpstub" +
" && chattr -i " + homedir + "/doms/" + domname + "/fastcgi-ssl/hs-phpstub" +
" && rm -rf " + homedir + "/doms/" + domname + " && rm -rf " + homedir + "/doms/" + domname +
" && invoke-rc.d apache2 reload >/dev/null 2>&1"); " && systemctl reload apache2.service >/dev/null 2>&1");
} }
private Processor createTriggerAcmebotProcessor(final EntityManager em, final Domain dom) { private Processor createTriggerAcmebotProcessor(final EntityManager em, final Domain dom) {

View File

@ -113,7 +113,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
return new ShellProcessor("grep -v '\"pri." + domName + "\"' /etc/bind/named.pri-zones > /etc/bind/named.pri-zones.tmp" + 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" + " && mv /etc/bind/named.pri-zones.tmp /etc/bind/named.pri-zones" +
" && rm -f /etc/bind/pri." + domName + " && rm -f /etc/bind/pri." + domName +
" && invoke-rc.d bind9 reload"); " && systemctl reload named.service");
} }
private Processor createAccountingRulesProc() { private Processor createAccountingRulesProc() {
@ -142,13 +142,13 @@ public class PacProcessorFactory implements EntityProcessorFactory {
private Processor createLinkSiteProc(final String pacDomain) { private Processor createLinkSiteProc(final String pacDomain) {
return new ShellProcessor("ln -sf /etc/apache2/sites-available/" + pacDomain + " /etc/apache2/sites-enabled/97-" + pacDomain return new ShellProcessor("ln -sf /etc/apache2/sites-available/" + pacDomain + " /etc/apache2/sites-enabled/97-" + pacDomain
+ " && invoke-rc.d apache2 reload >/dev/null 2>&1"); + " && systemctl reload apache2.service >/dev/null 2>&1");
} }
private Processor createUnlinkSiteProc(final String pacDomain) { private Processor createUnlinkSiteProc(final String pacDomain) {
return new ShellProcessor("rm -f /etc/apache2/sites-enabled/97-" + pacDomain return new ShellProcessor("rm -f /etc/apache2/sites-enabled/97-" + pacDomain
+ " && rm -f /etc/apache2/sites-available/" + pacDomain + "" + " && rm -f /etc/apache2/sites-available/" + pacDomain + ""
+ " && invoke-rc.d apache2 reload >/dev/null 2>&1"); + " && systemctl reload apache2.service >/dev/null 2>&1");
} }
private Processor createZonefileProc(final EntityManager em, final Pac pac) { private Processor createZonefileProc(final EntityManager em, final Pac pac) {
@ -281,7 +281,7 @@ public class PacProcessorFactory implements EntityProcessorFactory {
new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm", new VelocityProcessor("/de/hsadmin/mods/dom/named-hsh-conf.vm",
templateVars, "/etc/bind/named-hsh.conf.tmp", true), 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 ) " + 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 )") "|| ( mv /etc/bind/named-hsh.conf.tmp /etc/bind/named-hsh.conf && systemctl reload bind9.service )")
); );
} }

View File

@ -4,10 +4,10 @@
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<groupId>de.hsadmin.core</groupId> <groupId>de.hsadmin.core</groupId>
<artifactId>hsadmin-util</artifactId> <artifactId>hsadmin-util</artifactId>
<version>4.0.18</version> <version>4.0.15</version>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>11</java.version> <java.version>8</java.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
@ -24,8 +24,8 @@
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version> <version>3.11.0</version>
<configuration> <configuration>
<source>11</source> <source>8</source>
<target>11</target> <target>8</target>
</configuration> </configuration>
</plugin> </plugin>
</plugins> </plugins>

View File

@ -11,42 +11,31 @@ public class Config {
private static Logger LOG = Logger.getLogger(Config.class.getName()); private static Logger LOG = Logger.getLogger(Config.class.getName());
private static final String userDir = System.getProperty("user.dir"); private Properties props;
private static final String userHome = System.getProperty("user.home");
private final Properties props;
private Config() { private Config() {
props = new Properties(); props = new Properties();
initPropertiesFromFile(); File file = new File(System.getProperty("user.dir") + "/hsadmin.properties");
}
private void initPropertiesFromFile() {
final String baseName = "hsadmin";
File file = new File(userDir + "/" + baseName + ".properties");
if (!file.canRead()) { if (!file.canRead()) {
file = new File(userDir + "/conf/" + baseName + ".properties"); file = new File(System.getProperty("user.dir") + "/conf/hsadmin.properties");
} }
if (!file.canRead()) { if (!file.canRead()) {
file = new File(userHome + "/." + baseName + ".properties"); file = new File(System.getProperty("user.home") + "/.hsadmin.properties");
} }
if (!file.canRead()) { if (!file.canRead()) {
file = new File("/etc/hsadmin/" + baseName + ".properties"); file = new File("/etc/hsadmin/hsadmin.properties");
} }
if (!file.canRead()) { if (!file.canRead()) {
file = new File("/etc/" + baseName + ".properties"); file = new File("/etc/hsadmin.properties");
} }
if (file.canRead()) { if (file.canRead()) {
try { try {
LOG.info("Constructor - Properties-File: " + file.getAbsolutePath()); LOG.info("Constructor - Properties-File: " + file.getAbsolutePath());
props.load(new FileReader(file)); props.load(new FileReader(file));
} catch (Exception e) { } catch (Exception e) {
LOG.severe("reading properties failed: " + e.getMessage()); // should not happen
e.printStackTrace(); e.printStackTrace();
} }
} else {
final String errormsg = "reading properties failed: No properties file found";
LOG.severe(errormsg);
} }
} }