test.sh 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #!/bin/bash
  2. source mailcow.conf
  3. SOLR_OPTIONS=(
  4. "SOLR_HEAP"
  5. "SOLR_PORT"
  6. "SKIP_SOLR"
  7. )
  8. remove_solr_config_options() {
  9. sed -i --follow-symlinks '$a\' mailcow.conf
  10. for option in "${SOLR_OPTIONS[@]}"; do
  11. if [[ $option == "SOLR_HEAP" ]]; then
  12. if grep -q "${option}" mailcow.conf; then
  13. echo "Replacing SOLR_HEAP with \"${option}\" in mailcow.conf"
  14. sed -i '/# Solr heap size in MB\b/c\# Dovecot Indexing (FTS) Process heap size in MB, there is no recommendation, please see Dovecot docs.' mailcow.conf
  15. sed -i '/# Solr is a prone to run\b/c\# Flatcurve is replacing solr as FTS Indexer completely. It is supposed to be much more efficient in CPU and RAM consumption.' mailcow.conf
  16. sed -i 's/SOLR_HEAP/FTS_HEAP/g' mailcow.conf
  17. fi
  18. fi
  19. if [[ $option == "SKIP_SOLR" ]]; then
  20. if grep -q "${option}" mailcow.conf; then
  21. echo "Replacing $option in mailcow.conf with SKIP_FLATCURVE"
  22. sed -i '/\bSkip Solr on low-memory\b/c\# Skip Flatcurve (FTS) on low-memory systems or if you simply want to disable it.' mailcow.conf
  23. sed -i '/\bSolr is disabled by default\b/d' mailcow.conf
  24. sed -i '/\bDisable Solr or\b/d' mailcow.conf
  25. sed -i 's/SKIP_SOLR/SKIP_FLATCURVE/g' mailcow.conf
  26. fi
  27. fi
  28. if [[ $option == "SOLR_PORT" ]]; then
  29. if grep -q "${option}" mailcow.conf; then
  30. echo "Removing ${option} in mailcow.conf"
  31. sed -i '/\bSOLR_PORT\b/d' mailcow.conf
  32. fi
  33. fi
  34. done
  35. solr_volume=$(docker volume ls -qf name=^${COMPOSE_PROJECT_NAME}_solr-vol-1)
  36. if [[ -n $solr_volume ]]; then
  37. echo -e "\e[34mSolr has been replaced within mailcow since 2024-XX.\e[0m"
  38. sleep 1
  39. echo -e "\e[34mTherefore the volume $solr_volume is unused.\e[0m"
  40. sleep 1
  41. read -r -p "Would you like to remove the $solr_volume? " response
  42. if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]; then
  43. echo -e "\e[33mRemoving $solr_volume...\e[0m"
  44. docker volume rm $solr_volume
  45. if [[ $? != 0 ]]; then
  46. echo -e "\e[31mCould not remove the volume... Please remove it manually!\e[0m"
  47. else
  48. echo -e "\e[32mSucessfully removed $solr_volume!\e[0m"
  49. fi
  50. else
  51. echo "Ok! Not removing $solr_volume then."
  52. echo "Once you decided on removing the volume simply run docker volume rm $solr_volume to remove it manually."
  53. echo "This can be done anytime. mailcow does not use this volume anymore."
  54. fi
  55. fi
  56. }
  57. remove_solr_config_options