-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure.sh
executable file
·184 lines (170 loc) · 8.86 KB
/
configure.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
174
175
176
177
178
179
180
181
182
183
184
#! /bin/bash
source variables.conf
function makeDir()
{
if [ ! -d $1 ]
then
mkdir -v -p $1
fi
}
function makeDirs()
{
makeDir $ARCHIVE_HOME/apps
makeDir $ARCHIVE_HOME/backup
makeDir $ARCHIVE_HOME/backup/elasticsearch
makeDir $ARCHIVE_HOME/backup/mysql
makeDir $ARCHIVE_HOME/conf
makeDir $ARCHIVE_HOME/crawlreports
makeDir $ARCHIVE_HOME/drupal/oai/pmh
makeDir $ARCHIVE_HOME/fedora
makeDir $ARCHIVE_HOME/logs
makeDir $ARCHIVE_HOME/tmp
if [ ! -f $ARCHIVE_HOME/git/to.science.install/scripts/variables.conf ]; then
ln -s $ARCHIVE_HOME/git/to.science.install/variables.conf $ARCHIVE_HOME/git/to.science.install/scripts/variables.conf
fi
}
function createConfig()
{
export API_SECRET=`uuidgen`
export LABELS_SECRET=`uuidgen`
export FORMS_SECRET=`uuidgen`
export SKOS_LOOKUP_SECRET=`uuidgen`
export ADMIN_HASH=`echo -n ${ADMIN_SALT}${PASSWORD} | sha256sum | sed -e "s/ \-$//"`
export DATETIME=`date "+%Y-%m-%dT%H:%M:%SZ"`
substituteVars api.properties $ARCHIVE_HOME/conf/api.properties
substituteVars application.conf $ARCHIVE_HOME/conf/application.conf
substituteVars application.env $ARCHIVE_HOME/conf/application.env
substituteVars application.labels.conf $ARCHIVE_HOME/conf/application.labels.conf
substituteVars application.forms.conf $ARCHIVE_HOME/conf/application.forms.conf
substituteVars elasticsearch.service $ARCHIVE_HOME/conf/elasticsearch.service
substituteVars elasticsearch.yml $ARCHIVE_HOME/conf/elasticsearch.yml
substituteVars fedora.install.properties $ARCHIVE_HOME/conf/fedora.install.properties
substituteVars fedora.fcfg $ARCHIVE_HOME/conf/fedora.fcfg
substituteVars fedora-users.xml $ARCHIVE_HOME/conf/fedora-users.xml
substituteVars forms.env $ARCHIVE_HOME/conf/forms.env
substituteVars heritrix-start.sh $ARCHIVE_HOME/conf/heritrix-start.sh
substituteVars heritrix.service $ARCHIVE_HOME/conf/heritrix.service
substituteVars Identify.xml $ARCHIVE_HOME/conf/Identify.xml
substituteVars labels.env $ARCHIVE_HOME/conf/labels.env
substituteVars skos-lookup.env $ARCHIVE_HOME/conf/skos-lookup.env
substituteVars skos-lookup.service $ARCHIVE_HOME/conf/skos-lookup.service
substituteVars mail.properties $ARCHIVE_HOME/conf/mail.properties
substituteVars proai.properties $ARCHIVE_HOME/conf/proai.properties
substituteVars robots.txt $ARCHIVE_HOME/conf/robots.txt
substituteVars tomcat.setenv.sh $ARCHIVE_HOME/conf/tomcat.setenv.sh
substituteVars tomcat.logging.properties $ARCHIVE_HOME/conf/tomcat.logging.properties
substituteVars site.conf $ARCHIVE_HOME/conf/site.conf
substituteVars site.ssl.conf $ARCHIVE_HOME/conf/site.ssl.conf
substituteVars wayback.ssl.conf $ARCHIVE_HOME/conf/wayback.$DOMAIN.conf
substituteVars tomcat.service $ARCHIVE_HOME/conf/tomcat.service
substituteVars tomcat-users.xml $ARCHIVE_HOME/conf/tomcat-users.xml
substituteVars tomcat.conf $ARCHIVE_HOME/conf/tomcat.conf
substituteVars toscience-api.service $ARCHIVE_HOME/conf/toscience-api.service
substituteVars toscience-labels.service $ARCHIVE_HOME/conf/toscience-labels.service
substituteVars toscience-forms.service $ARCHIVE_HOME/conf/toscience-forms.service
cp templates/favicon.ico $ARCHIVE_HOME/conf/favicon.ico
cp templates/datacite.cert $ARCHIVE_HOME/conf/datacite.cert
# Erzeugt ein selbstsigniertes Zertifikat und einen privaten Schlüssel für das Backend (API)
# Quelle: https://linuxconfig.org/how-to-generate-a-self-signed-ssl-certificate-on-linux
# zweite Quelle: https://superuser.com/questions/1160382/how-to-pass-arguments-like-country-name-to-openssl-when-creating-self-signed-c
openssl req -x509 -newkey rsa:4096 -sha512 -days 365 -nodes -out $SSL_PUBLIC_CERT_BACKEND -keyout $SSL_PRIVATE_KEY_BACKEND -subj "/C=$SSL_PUBLIC_CERT_COUNTRY/ST=$SSL_PUBLIC_CERT_STATE/L=$SSL_PUBLIC_CERT_LOCATION/O=$SSL_PUBLIC_CERT_ORGANIZATION/OU=$SSL_PUBLIC_CERT_ORGANIZATION_UNIT/CN=$APIDOMAIN"
# Erzeugt ein selbstsigniertes Zertifikat und einen privaten Schlüssel für das Frontend (Drupal)
openssl req -x509 -newkey rsa:4096 -sha512 -days 365 -nodes -out $SSL_PUBLIC_CERT_FRONTEND -keyout $SSL_PRIVATE_KEY_FRONTEND -subj "/C=$SSL_PUBLIC_CERT_COUNTRY/ST=$SSL_PUBLIC_CERT_STATE/L=$SSL_PUBLIC_CERT_LOCATION/O=$SSL_PUBLIC_CERT_ORGANIZATION/OU=$SSL_PUBLIC_CERT_ORGANIZATION_UNIT/CN=$DOMAIN"
if [ -f $KEYSTORE ]; then
rm $KEYSTORE
fi
# Erzeugt einen neuen Schlüsselspeicher
# Quelle: https://stackoverflow.com/questions/47434877/how-to-generate-keystore-and-truststore
# 1. Schlüsselspeicher generieren (auf dem Server):
keytool -genkey -storetype pkcs12 -noprompt -alias toscience -keyalg RSA -keysize 4096 -dname "C=$SSL_PUBLIC_CERT_COUNTRY, ST=$SSL_PUBLIC_CERT_STATE, L=$SSL_PUBLIC_CERT_LOCATION, O=$SSL_PUBLIC_CERT_ORGANIZATION, OU=$SSL_PUBLIC_CERT_ORGANIZATION_UNIT, CN=$DOMAIN" -keystore $KEYSTORE -storepass $STOREPASS -keypass $KEYPASS
# 2. Importiert das selbstsignierte Zertifikat für das Backend in den Schlüsselspeicher:
keytool -import -trustcacerts -noprompt -alias to.science.api -file $SSL_PUBLIC_CERT_BACKEND -keystore $KEYSTORE -storepass $STOREPASS -keypass $KEYPASS
# 3. Importiert das selbstsignierte Zertifikat für das Frontend in den Schlüsselspeicher:
keytool -import -trustcacerts -noprompt -alias to.science.drupal -file $SSL_PUBLIC_CERT_FRONTEND -keystore $KEYSTORE -storepass $STOREPASS -keypass $KEYPASS
# Importiert ein (abgelaufenes) Zertifikat für Datacite in den Schlüsselspeicher:
# keytool -import -trustcacerts -noprompt -alias datacite -file $ARCHIVE_HOME/conf/datacite.cert -keystore $KEYSTORE -storepass $STOREPASS -keypass $KEYPASS
# Importiert ein Zertifikat für heritrix in den Schlüsselspeicher:
keytool -genkey -storetype pkcs12 -noprompt -alias heritrix -keyalg RSA -keysize 4096 -dname "C=$SSL_PUBLIC_CERT_COUNTRY, ST=$SSL_PUBLIC_CERT_STATE, L=$SSL_PUBLIC_CERT_LOCATION, O=$SSL_PUBLIC_CERT_ORGANIZATION, OU=$SSL_PUBLIC_CERT_ORGANIZATION_UNIT, CN=$HERITRIX_URL" -validity 3650 -keystore $KEYSTORE -storepass $STOREPASS -keypass $KEYPASS
}
function substituteVars()
{
file=templates/$1
target=$2
sed -e "s;\$SERVER;$SERVER;g" \
-e "s;\$DOMAIN;$DOMAIN;g" \
-e "s;\$ADMIN_PASSWORD;$ADMIN_PASSWORD;g" \
-e "s;\$ADMIN_SALT;$ADMIN_SALT;g" \
-e "s;\$ADMIN_HASH;$ADMIN_HASH;g" \
-e "s;\$ADMIN_PREFIX;$ADMIN_PREFIX;g" \
-e "s;\$ADMIN_USER;$ADMIN_USER;g" \
-e "s;\$ADMIN_EMAIL;$ADMIN_EMAIL;g" \
-e "s;\$APIDOMAIN;$APIDOMAIN;g" \
-e "s;\$API_USER;$API_USER;g" \
-e "s;\$API_SECRET;$API_SECRET;g" \
-e "s;\$LABELS_SECRET;$LABELS_SECRET;g" \
-e "s;\$FORMS_SECRET;$FORMS_SECRET;g" \
-e "s;\$APACHE_LOGVERZ;$APACHE_LOGVERZ;g" \
-e "s;\$ARCHIVE_HOME;$ARCHIVE_HOME;g" \
-e "s;\$BACKEND;$BACKEND;g" \
-e "s;\$CRONJOBS_DIR;$CRONJOBS_DIR;g" \
-e "s;\$DATACITE_PASSWORD;$DATACITE_PASSWORD;g" \
-e "s;\$DATACITE_USER;$DATACITE_USER;g" \
-e "s;\$DATACITE_URL;$DATACITE_URL;g" \
-e "s;\$DATETIME;$DATETIME;g" \
-e "s;\$DOIPREFIX;$DOIPREFIX;g" \
-e "s;\$DOIRESOLVER;$DOIRESOLVER;g" \
-e "s;\$ELASTICSEARCH;$ELASTICSEARCH;g" \
-e "s;\$ELASTICSEARCH_CONF;$ELASTICSEARCH_CONF;g" \
-e "s;\$ELASTIC_PORT;$ELASTIC_PORT;g" \
-e "s;\$EMAIL_RECIPIENT_ADMIN_USERS;$EMAIL_RECIPIENT_ADMIN_USERS;g" \
-e "s;\$EMAIL_RECIPIENT_PROJECT_ADMIN;$EMAIL_RECIPIENT_PROJECT_ADMIN;g" \
-e "s;\$EMAIL_RECIPIENTS_JAVA_MAILS;$EMAIL_RECIPIENTS_JAVA_MAILS;g" \
-e "s;\$EMAIL;$EMAIL;g" \
-e "s;\$FEDORA_USER;$FEDORA_USER;g" \
-e "s;\$FEDORA_PASSWORD;$FEDORA_PASSWORD;g" \
-e "s;\$FRONTEND;$FRONTEND;g" \
-e "s;\$HERITRIX_DATA;$HERITRIX_DATA;g" \
-e "s;\$HERITRIX_DIR;$HERITRIX_DIR;g" \
-e "s;\$HERITRIX_URL;$HERITRIX_URL;g" \
-e "s;\$HERITRIX_PASSWORD;$HERITRIX_PASSWORD;g" \
-e "s;\$INDEXNAME;$INDEXNAME;g" \
-e "s;\$IP;$IP;g" \
-e "s;\$KEYSTORE;$KEYSTORE;g" \
-e "s;\$STOREPASS;$STOREPASS;g" \
-e "s;\$KEYPASS;$KEYPASS;g" \
-e "s;\$LABELS_PASSWORD;$LABELS_PASSWORD;g" \
-e "s;\$LINUX_GROUP;$LINUX_GROUP;g" \
-e "s;\$LINUX_USER;$LINUX_USER;g" \
-e "s;\$MYSQL_PASSWORD;$MYSQL_PASSWORD;g" \
-e "s;\$MYSQL_LABELS_PASSWORD;$MYSQL_LABELS_PASSWORD;g" \
-e "s;\$MYSQL_OAI_PASSWORD;$MYSQL_OAI_PASSWORD;g" \
-e "s%\$NAMESPACE%$NAMESPACE%g" \
-e "s;\$PASSWORD;$PASSWORD;g" \
-e "s;\$PLAYPORT;$PLAYPORT;g" \
-e "s;\$PROJECT;$PROJECT;g" \
-e "s;\$REGAL_ADMIN;$REGAL_ADMIN;g" \
-e "s;\$REGAL_APP;$REGAL_APP;g" \
-e "s;\$REGAL_BACKUP;$REGAL_BACKUP;g" \
-e "s;\$REGAL_LOGS;$REGAL_LOGS;g" \
-e "s;\$REGAL_PASSWORD;$REGAL_PASSWORD;g" \
-e "s;\$REGAL_TMP;$REGAL_TMP;g" \
-e "s;\$SKOS_LOOKUP_SECRET;$SKOS_LOOKUP_SECRET;g" \
-e "s;\$SSL_PUBLIC_CERT_BACKEND;$SSL_PUBLIC_CERT_BACKEND;g" \
-e "s;\$SSL_PRIVATE_KEY_BACKEND;$SSL_PRIVATE_KEY_BACKEND;g" \
-e "s;\$SSL_PUBLIC_CERT_FRONTEND;$SSL_PUBLIC_CERT_FRONTEND;g" \
-e "s;\$SSL_PRIVATE_KEY_FRONTEND;$SSL_PRIVATE_KEY_FRONTEND;g" \
-e "s;\$SSL_CHAIN_FRONTEND;$SSL_CHAIN_FRONTEND;g" \
-e "s;\$STATS_LOG;$STATS_LOG;g" \
-e "s;\$TMPDIR;$TMPDIR;g" \
-e "s;\$TOMCAT_CONF;$TOMCAT_CONF;g" \
-e "s;\$TOMCAT_HOME;$TOMCAT_HOME;g" \
-e "s;\$TOMCAT_PORT;$TOMCAT_PORT;g" \
-e "s;\$URNBASE;$URNBASE;g" \
-e "s;\$URNSNID;$URNSNID;g" \
-e "s;\$VERSION;$VERSION;g" \
-e "s;\$WAYBACK_SERVER;$WAYBACK_SERVER;g" \
-e "s;\$WAYBACK_PORT;$WAYBACK_PORT;g" \
-e "s;\$WHITELIST;$WHITELIST;g" $file > $target
}
makeDirs
createConfig