-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall_ejbca.sh
executable file
·173 lines (135 loc) · 7.23 KB
/
install_ejbca.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
#!/bin/bash
# Author: Kobus Grobler
#
EJBCA_VERSION="6_15_2_6"
SHASUM="2ecd4c23e4d34eb590d50d7fb0d5d5c37b48aa00be115214ddad1d6051ce2a5c"
WILDFLY_HOME="/opt/wildfly"
DB_VERSION="2.2.6"
DB_SHASUM="4d28fbd8fd4ea239b0ef9482f56ce77e2ef197a60d523a8ee3c84eb984fc76fe"
EHSM_VERSION=2.7
EHSM_SHASUM="8e6dd05577456a7a4e01099bedbb3e2c953b7402358b10fa51c4e5d8b33ad58f"
sudo apt-get install ant mariadb-server
sudo usermod -a -G plugdev wildfly
sudo mysql -u root < mariadb.sql
sudo mysql -u root < create-tables-ejbca-mysql.sql
if [ ! -f eHSM-pkcs11-${EHSM_VERSION}.deb ]; then
wget https://ellipticsecure.com/downloads/eHSM-pkcs11-${EHSM_VERSION}.deb
if [ $? -ne 0 ]; then
exit 1;
fi
fi
echo "${EHSM_SHASUM} eHSM-pkcs11-${EHSM_VERSION}.deb" | shasum -a 256 -c
if [ $? -ne 0 ]; then
exit 1;
fi
sudo dpkg -i eHSM-pkcs11-${EHSM_VERSION}.deb
if [ ! -f ejbca_ce_$EJBCA_VERSION.zip ]; then
wget https://sourceforge.net/projects/ejbca/files/ejbca6/ejbca_$EJBCA_VERSION/ejbca_ce_$EJBCA_VERSION.zip/download -O ejbca_ce_$EJBCA_VERSION.zip
if [ $? -ne 0 ]; then
exit 1;
fi
fi
echo "${SHASUM} ejbca_ce_$EJBCA_VERSION.zip" | shasum -a 256 -c
if [ $? -ne 0 ]; then
exit 1;
fi
if [ ! -d ejbca_ce_$EJBCA_VERSION ]; then
unzip ejbca_ce_$EJBCA_VERSION.zip
fi
# prep wildfly
grep -qxF 'JAVA_OPTS="-Xmx2048m"'\
${WILDFLY_HOME}/bin/standalone.conf || sudo bash -c 'echo ''JAVA_OPTS=\"-Xmx2048m\"''\
>> /opt/wildfly/bin/standalone.conf'
if [ ! -f mariadb-java-client.jar ]; then
wget https://downloads.mariadb.com/Connectors/java/connector-java-${DB_VERSION}/mariadb-java-client-${DB_VERSION}.jar -O mariadb-java-client.jar
fi
echo "${DB_SHASUM} mariadb-java-client.jar" | shasum -a 256 -c
if [ $? -ne 0 ]; then
exit 1;
fi
sudo cp mariadb-java-client.jar ${WILDFLY_HOME}/standalone/deployments/
sudo chown -RH wildfly: /opt/wildfly/standalone/deployments/
echo "Installing mysql driver..."
sudo service wildfly restart
wait_for_server() {
COUNTER=1
sleep 2
until [ $(curl --output /dev/null --silent --head --fail http://localhost:8080/) ] || [ $COUNTER -eq 10 ]
do
echo "waiting for service to start...." $COUNTER
sleep 2
((COUNTER++))
done
}
wait_for_server
sudo cp *.properties ejbca_ce_$EJBCA_VERSION/conf/
sudo chown -RH wildfly: ejbca_ce_$EJBCA_VERSION/
echo "updating wildfly datasource..."
sudo -u wildfly -g wildfly ${WILDFLY_HOME}/bin/jboss-cli.sh -c 'data-source add --name=EjbcaDS --driver-name="mariadb-java-client.jar" --connection-url="jdbc:mysql://127.0.0.1:3306/ejbca" --jndi-name="java:/EjbcaDS" --use-ccm=true --driver-class="org.mariadb.jdbc.Driver" --user-name="ejbca" --password="ejbca" --validate-on-match=true --background-validation=false --prepared-statements-cache-size=50 --share-prepared-statements=true --min-pool-size=5 --max-pool-size=150 --pool-prefill=true --transaction-isolation=TRANSACTION_READ_COMMITTED --check-valid-connection-sql="select 1;"'
sudo -u wildfly -g wildfly ${WILDFLY_HOME}/bin/jboss-cli.sh -c "/subsystem=remoting/http-connector=http-remoting-connector:write-attribute(name=connector-ref,value=remoting),
/socket-binding-group=standard-sockets/socket-binding=remoting:add(port=4447,interface=management),
/subsystem=undertow/server=default-server/http-listener=remoting:add(socket-binding=remoting,enable-http2=true),
/subsystem=infinispan/cache-container=ejb:remove(),
/subsystem=infinispan/cache-container=server:remove(),
/subsystem=infinispan/cache-container=web:remove(),
/subsystem=ejb3/cache=distributable:remove(),
/subsystem=ejb3/passivation-store=infinispan:remove(),
/subsystem=logging/logger=org.ejbca:add(level=INFO),
/subsystem=logging/logger=org.cesecore:add(level=INFO)"
#sudo -u wildfly -g wildfly ${WILDFLY_HOME}/bin/jboss-cli.sh -c ':reload'
sudo service wildfly restart
wait_for_server
echo "Deploying ear..."
sudo -u wildfly -g wildfly ant -f ejbca_ce_$EJBCA_VERSION/build.xml -q clean deployear
wait_for_ejbca() {
COUNTER=1
sleep 5
until [ $(curl --output /dev/null --silent --head --fail http://localhost:8080/ejbca/) ] || [ $COUNTER -eq 10 ]
do
echo "waiting for ejbca to start...."
sleep 2
((COUNTER++))
done
}
wait_for_ejbca
sudo -u wildfly -g wildfly ant -f ejbca_ce_$EJBCA_VERSION/build.xml runinstall
sudo -u wildfly -g wildfly ant -f ejbca_ce_$EJBCA_VERSION/build.xml deploy-keystore
sudo cp -i -r ejbca_ce_$EJBCA_VERSION/p12/ .
echo "removing listeners..."
sudo -u wildfly -g wildfly ${WILDFLY_HOME}/bin/jboss-cli.sh -c '/subsystem=undertow/server=default-server/http-listener=default:remove(),
/subsystem=undertow/server=default-server/https-listener=https:remove(),
/socket-binding-group=standard-sockets/socket-binding=http:remove(),
/socket-binding-group=standard-sockets/socket-binding=https:remove(),
:reload'
sleep 6
wait_for_ejbca
echo "installing listeners..."
sudo -u wildfly -g wildfly ${WILDFLY_HOME}/bin/jboss-cli.sh -c '
/interface=http:add(inet-address="0.0.0.0"),
/interface=httpspub:add(inet-address="0.0.0.0"),
/interface=httpspriv:add(inet-address="0.0.0.0"),
/socket-binding-group=standard-sockets/socket-binding=http:add(port="8080",interface="http"),
/socket-binding-group=standard-sockets/socket-binding=httpspub:add(port="8442",interface="httpspub"),
/socket-binding-group=standard-sockets/socket-binding=httpspriv:add(port="8443",interface="httpspriv"),
/subsystem=elytron/key-store=httpsKS:add(path="keystore/keystore.jks",relative-to=jboss.server.config.dir,credential-reference={clear-text="serverpwd"},type=JKS),
/subsystem=elytron/key-store=httpsTS:add(path="keystore/truststore.jks",relative-to=jboss.server.config.dir,credential-reference={clear-text="changeit"},type=JKS),
/subsystem=elytron/key-manager=httpsKM:add(key-store=httpsKS,algorithm="SunX509",credential-reference={clear-text="serverpwd"}),
/subsystem=elytron/trust-manager=httpsTM:add(key-store=httpsTS),
/subsystem=elytron/server-ssl-context=httpspub:add(key-manager=httpsKM,protocols=["TLSv1.2"]),
/subsystem=elytron/server-ssl-context=httpspriv:add(key-manager=httpsKM,protocols=["TLSv1.2"],trust-manager=httpsTM,need-client-auth=true,authentication-optional=false,want-client-auth=true),
/subsystem=undertow/server=default-server/http-listener=http:add(socket-binding="http", redirect-socket="httpspriv"),
/subsystem=undertow/server=default-server/https-listener=httpspub:add(socket-binding="httpspub", ssl-context="httpspub", max-parameters=2048),
/subsystem=undertow/server=default-server/https-listener=httpspriv:add(socket-binding="httpspriv", ssl-context="httpspriv", max-parameters=2048)'
sudo service wildfly restart
echo "Waiting for wildfly to start on new ports..."
wait_for_ejbca
echo "Adding wsdl services..."
sudo -u wildfly -g wildfly ${WILDFLY_HOME}/bin/jboss-cli.sh -c '/system-property=org.apache.catalina.connector.URI_ENCODING:add(value="UTF-8"),
/system-property=org.apache.catalina.connector.USE_BODY_ENCODING_FOR_QUERY_STRING:add(value=true),
/system-property=org.apache.tomcat.util.buf.UDecoder.ALLOW_ENCODED_SLASH:add(value=true),
/system-property=org.apache.tomcat.util.http.Parameters.MAX_COUNT:add(value=2048),
/system-property=org.apache.catalina.connector.CoyoteAdapter.ALLOW_BACKSLASH:add(value=true),
/subsystem=webservices:write-attribute(name=wsdl-host, value=jbossws.undefined.host),
/subsystem=webservices:write-attribute(name=modify-wsdl-address, value=true)'
sudo service wildfly restart
wait_for_ejbca