blob: 1c5c6f51f0d42d1949f52235ee600442354a6819 [file] [log] [blame]
Matthias Andreas Benkardb382b102021-01-02 15:32:21 +01001#!/bin/bash
2
3if [[ "${SKIP_SOLR}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
4 echo "SKIP_SOLR=y, skipping Solr..."
5 sleep 365d
6 exit 0
7fi
8
9MEM_TOTAL=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
10
11if [[ "${1}" != "--bootstrap" ]]; then
12 if [ ${MEM_TOTAL} -lt "2097152" ]; then
13 echo "System memory less than 2 GB, skipping Solr..."
14 sleep 365d
15 exit 0
16 fi
17fi
18
19set -e
20
21# run the optional initdb
22. /opt/docker-solr/scripts/run-initdb
23
24# fixing volume permission
25[[ -d /opt/solr/server/solr/dovecot-fts/data ]] && chown -R solr:solr /opt/solr/server/solr/dovecot-fts/data
26if [[ "${1}" != "--bootstrap" ]]; then
27 sed -i '/SOLR_HEAP=/c\SOLR_HEAP="'${SOLR_HEAP:-1024}'m"' /opt/solr/bin/solr.in.sh
28else
29 sed -i '/SOLR_HEAP=/c\SOLR_HEAP="256m"' /opt/solr/bin/solr.in.sh
30fi
31
32if [[ "${1}" == "--bootstrap" ]]; then
33 echo "Creating initial configuration"
34 echo "Modifying default config set"
35 cp /solr-config-7.7.0.xml /opt/solr/server/solr/configsets/_default/conf/solrconfig.xml
36 cp /solr-schema-7.7.0.xml /opt/solr/server/solr/configsets/_default/conf/schema.xml
37 rm /opt/solr/server/solr/configsets/_default/conf/managed-schema
38
39 echo "Starting local Solr instance to setup configuration"
40 gosu solr start-local-solr
41
42 echo "Creating core \"dovecot-fts\""
43 gosu solr /opt/solr/bin/solr create -c "dovecot-fts"
44
45 # See https://github.com/docker-solr/docker-solr/issues/27
46 echo "Checking core"
47 while ! wget -O - 'http://localhost:8983/solr/admin/cores?action=STATUS' | grep -q instanceDir; do
48 echo "Could not find any cores, waiting..."
49 sleep 3
50 done
51
52 echo "Created core \"dovecot-fts\""
53
54 echo "Stopping local Solr"
55 gosu solr stop-local-solr
56
57 exit 0
58fi
59
60exec gosu solr solr-foreground
61