solr.sh 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. #!/bin/bash
  2. if [[ "${FLATCURVE_EXPERIMENTAL}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
  3. echo "FLATCURVE_EXPERIMENTAL=y, skipping Solr but enabling Flatcurve as FTS for Dovecot!"
  4. echo "Solr will be removed in the future!"
  5. sleep 365d
  6. exit 0
  7. elif [[ "${SKIP_SOLR}" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
  8. echo "SKIP_SOLR=y, skipping Solr..."
  9. echo "HINT: You could try the newer FTS Backend Flatcurve, which is currently in experimental state..."
  10. echo "Simply set FLATCURVE_EXPERIMENTAL=y inside your mailcow.conf and restart the stack afterwards!"
  11. echo "Solr will be removed in the future!"
  12. sleep 365d
  13. exit 0
  14. fi
  15. MEM_TOTAL=$(awk '/MemTotal/ {print $2}' /proc/meminfo)
  16. if [[ "${1}" != "--bootstrap" ]]; then
  17. if [ ${MEM_TOTAL} -lt "2097152" ]; then
  18. echo "System memory less than 2 GB, skipping Solr..."
  19. sleep 365d
  20. exit 0
  21. fi
  22. fi
  23. set -e
  24. # run the optional initdb
  25. . /opt/docker-solr/scripts/run-initdb
  26. # fixing volume permission
  27. [[ -d /opt/solr/server/solr/dovecot-fts/data ]] && chown -R solr:solr /opt/solr/server/solr/dovecot-fts/data
  28. if [[ "${1}" != "--bootstrap" ]]; then
  29. sed -i '/SOLR_HEAP=/c\SOLR_HEAP="'${SOLR_HEAP:-1024}'m"' /opt/solr/bin/solr.in.sh
  30. else
  31. sed -i '/SOLR_HEAP=/c\SOLR_HEAP="256m"' /opt/solr/bin/solr.in.sh
  32. fi
  33. if [[ "${1}" == "--bootstrap" ]]; then
  34. echo "Creating initial configuration"
  35. echo "Modifying default config set"
  36. cp /solr-config-7.7.0.xml /opt/solr/server/solr/configsets/_default/conf/solrconfig.xml
  37. cp /solr-schema-7.7.0.xml /opt/solr/server/solr/configsets/_default/conf/schema.xml
  38. rm /opt/solr/server/solr/configsets/_default/conf/managed-schema
  39. echo "Starting local Solr instance to setup configuration"
  40. gosu solr start-local-solr
  41. echo "Creating core \"dovecot-fts\""
  42. gosu solr /opt/solr/bin/solr create -c "dovecot-fts"
  43. # See https://github.com/docker-solr/docker-solr/issues/27
  44. echo "Checking core"
  45. while ! wget -O - 'http://localhost:8983/solr/admin/cores?action=STATUS' | grep -q instanceDir; do
  46. echo "Could not find any cores, waiting..."
  47. sleep 3
  48. done
  49. echo "Created core \"dovecot-fts\""
  50. echo "Stopping local Solr"
  51. gosu solr stop-local-solr
  52. exit 0
  53. fi
  54. echo "Starting up Solr..."
  55. echo -e "\e[31mSolr is deprecated! You can try the new FTS System now by enabling FLATCURVE_EXPERIMENTAL=y inside mailcow.conf and restarting the stack\e[0m"
  56. echo -e "\e[31mSolr will be removed completely soon!\e[0m"
  57. sleep 15
  58. exec gosu solr solr-foreground