-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·181 lines (156 loc) · 7.35 KB
/
setup.sh
File metadata and controls
executable file
·181 lines (156 loc) · 7.35 KB
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
#!/bin/bash
#
# This script contains a number of setup actions which help prepare the dataverse and Skosmos environments.
# Load environment variables.
set -a
source .env
set +a
echo "Bootstrap container: $BOOTSTRAP_CONTAINER"
# Initiating the submodule and fetching any changes.
git submodule init && git submodule update --remote
# Adding the docker-compose variables for dataverse
#cp dataverse/dot_env dataverse/.env
# Check if we have an .env file
if [ ! -f dataverse/.env ]; then
echo "No .env file found in dataverse submodule, copying from dataverse/dot_env..."
cp dataverse/dot_env dataverse/.env
else
echo ".env file already exists in dataverse; analyzing..."
# first read the existing .env file to get the values of the variables
source dataverse/.env
cp dataverse/dot_env dataverse/.env
# if we have _CT_DATAVERSE_SITEURL, then add it to the .env file
if [ -z "$_CT_DATAVERSE_SITEURL" ]; then
echo "_CT_DATAVERSE_SITEURL is not set, using dataverse/dot_env file..."
else
echo "_CT_DATAVERSE_SITEURL is set, adding it to the .env file..."
echo "" >> dataverse/.env
echo "_CT_DATAVERSE_SITEURL=$_CT_DATAVERSE_SITEURL" >> dataverse/.env
fi
# if we have _CT_DATAVERSE_FQDN, then add it to the .env file, otherwise we will use the value from the dataverse/dot_env file
if [ -z "$_CT_DATAVERSE_FQDN" ]; then
echo "_CT_DATAVERSE_FQDN is not set, using dataverse/dot_env file..."
else
echo "_CT_DATAVERSE_FQDN is set, adding it to the .env file..."
echo "" >> dataverse/.env
echo "_CT_DATAVERSE_FQDN=$_CT_DATAVERSE_FQDN" >> dataverse/.env
fi
fi
# Create Traefik network
docker network create traefik
# Upping the Dataverse stack.
docker compose -f dataverse/docker-compose.yml up -d
# Setup traefik container
docker compose -f utils/traefik/docker-compose.yml up -d
# Function to check if the bootstrap container is still running
is_running() {
status=$(docker inspect --format='{{.State.Status}}' "$BOOTSTRAP_CONTAINER")
if [ "$status" = "exited" ]; then
return 1
else
return 0
fi
}
# Wait for the bootstrap container to finish
echo "Waiting for the bootstrap container to finish..."
while is_running; do
sleep 5
echo "Still waiting..."
done
echo "Bootstrapping dataverse has finished!"
wait_for_dataverse_up() {
while true; do
STATUS_CODE=$(docker exec "$DATAVERSE_CONTAINER" curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/api/info/version)
if [ "$STATUS_CODE" -eq 200 ]; then
echo "Dataverse is up."
break
else
echo "Still waiting... (HTTP $STATUS_CODE)"
sleep 5
fi
done
}
# wait for Dataverse to be up
echo "Waiting for Dataverse to be up..."
wait_for_dataverse_up
# Solr should be ok for Dataverse already
# However, this seems NOT to be the case!
# Import SOLR schema and config,
# supplied with the release of the deployed Dataverse version!
echo "--- Importing SOLR schema and config..."
sh utils/solr/copy_solr.sh "$SOLR_CONTAINER"
echo "--- SOLR schema and config imported!"
# Loading our metadata blocks.
echo "--- Loading metadata blocks..."
CUSTOM_METADATA_DIR="utils/Custom-Metadata-Blocks/tsv_files/"
cp utils/metadata/* "$CUSTOM_METADATA_DIR"
sh $CUSTOM_METADATA_DIR/upload.sh "$DATAVERSE_CONTAINER"
echo "--- Metadata blocks loaded!"
# Setup subverses and import licenses
echo "--- Setting up subverses and importing licenses..."
sh utils/dataverse/run_py_scripts.sh "$POSTGRES_CONTAINER"
echo "--- Subverses and licenses setup complete!"
# Setup dutch translation
echo "--- Setting up dutch translation..."
sh utils/language_setup.sh "$DATAVERSE_CONTAINER"
echo "--- Dutch translation setup complete!"
# Copy adjusted robots.txt
echo "--- Copying adjusted robots.txt..."
sh utils/dataverse/fix_robots_txt.sh "$DATAVERSE_CONTAINER"
echo "--- Adjusted robots.txt copied!"
# Configure web analytics
echo "--- Configuring web analytics..."
sh utils/dataverse/configure_web_analytics.sh "$DATAVERSE_CONTAINER" "$DATAVERSE_WEB_ANALYTICS_ID"
echo "--- Web analytics configured!"
# Configure NavbarGuidesUrl
echo "--- Configuring NavbarGuidesUrl..."
docker exec "$DATAVERSE_CONTAINER" curl -X PUT -d "$DATAVERSE_NAVBAR_GUIDES_URL" http://localhost:8080/api/admin/settings/:NavbarGuidesUrl
echo "--- NavbarGuidesUrl configured!"
# Configure Notifications
echo "--- Configuring Notifications..."
# Enable to show options in UI
docker exec "$DATAVERSE_CONTAINER" curl -X PUT -d 'true' http://localhost:8080/api/admin/settings/:ShowMuteOptions
# Mute all that have to do with Dataset import, create and publish
docker exec "$DATAVERSE_CONTAINER" curl -X PUT -d 'CREATEDS,CREATEDV,DATASETCREATED,FILESYSTEMIMPORT,PUBLISHEDDS,PUBLISHFAILED_PIDREG,STATUSUPDATED,SUBMITTEDDS,WORKFLOW_FAILURE,WORKFLOW_SUCCESS,SUBMITTEDDS,WORKFLOW_FAILURE,WORKFLOW_SUCCESS' http://localhost:8080/api/admin/settings/:AlwaysMuted
echo "--- Notifications configured!"
# Note that the schema is changed by the following action
# Update the schema.xml file with our custom fields
echo "--- Updating schema.xml file with new fields..."
sh utils/solr/schema-update/update.sh "$DATAVERSE_CONTAINER" "$SOLR_CONTAINER"
echo "--- Schema.xml file updated!"
# Turn of sign up options
echo "--- Turning off sign up options..."
docker exec "$DATAVERSE_CONTAINER" curl -X PUT -d 'false' http://localhost:8080/api/admin/settings/:AllowSignUp
echo "--- Sign up options turned off!"
# Setup cvocconf
echo "--- Setting up cvocconf..."
docker cp utils/external_vocabularies/cvocconf.json "$DATAVERSE_CONTAINER":/opt/payara/cvocconf.json
docker exec "$DATAVERSE_CONTAINER" curl -X PUT --upload-file cvocconf.json http://localhost:8080/api/admin/settings/:CVocConf
docker exec "$DATAVERSE_CONTAINER" mkdir /opt/payara/deployments/dataverse/custom
docker cp utils/external_vocabularies/skosmos.js "$DATAVERSE_CONTAINER":/opt/payara/deployments/dataverse/custom/skosmos.js
# Uncomment the following for ror and cvocutils after we have fixed it on production
#docker cp utils/external_vocabularies/cvocutils.js "$DATAVERSE_CONTAINER":/opt/payara/deployments/dataverse/custom/cvocutils.js
#docker cp utils/external_vocabularies/ror.js "$DATAVERSE_CONTAINER":/opt/payara/deployments/dataverse/custom/ror.js
echo "--- cvocconf setup complete!"
# Install exporter jar files
echo "--- Installing exporter jar files..."
sh utils/dataverse/install_exporters.sh
echo "--- Exporter jar files copied!"
# Copy dataset.xhtml with file and version tab removed to volume.
echo "--- Copying dataset.xhtml with file and version tab removed..."
# test if we have the file in a target dir, assuming that is a Dataverse development setup
if [ -f dataverse/target/dataverse/dataset.xhtml ]; then
echo "dataset.xhtml exists in target dir, NOT copying assuming Dataverse development setup..."
else
echo "dataset.xhtml does not exist in target dir, copying to dataverse container..."
#docker cp utils/dataverse/mounts/dataset.xhtml "$DATAVERSE_CONTAINER:/opt/payara/deployments/dataverse/dataset.xhtml"
utils/dataverse/mounts/update.sh "$DATAVERSE_CONTAINER"
fi
echo "--- dataset.xhtml copied!"
echo "Restarting dataverse container..."
# Restart the dataverse container to pick up the new dataset.xhtml
docker restart "$DATAVERSE_CONTAINER"
echo "--- Setup complete!"
echo "Please wait for Dataverse to start up, this can take a while depending on your machine."
# could check if the container is running...
#echo "You can now access the dataverse at http://localhost:8080 and Skosmos at http://localhost:8081"