preinstall.sh 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/bash
  2. #
  3. # packager.io preinstall script
  4. #
  5. #
  6. # Make sure that after installation/update there can be only one sprockets manifest,
  7. # the one coming from the package. The package manager will ignore any duplicate files
  8. # which might come from a backup restore and/or a manual 'assets:precompile' command run.
  9. # These duplicates can cause the application to fail, however.
  10. #
  11. rm -f /opt/zammad/public/assets/.sprockets-manifest-*.json || true
  12. #
  13. # TEMPORARILY DISABLED DUE TO OPEN ISSUES
  14. #
  15. # # Ensure database connectivity
  16. # if [[ -f /opt/zammad/config/database.yml ]]; then
  17. # DB_HOST="$(grep -m 1 '^[[:space:]]*host:' < /opt/zammad/config/database.yml | sed -e 's/.*host:[[:space:]]*//g')"
  18. # DB_PORT="$(grep -m 1 '^[[:space:]]*port:' < /opt/zammad/config/database.yml | sed -e 's/.*port:[[:space:]]*//g')"
  19. # DB_SOCKET="$(grep -m 1 '^[[:space:]]*socket:' < /opt/zammad/config/database.yml | sed -e 's/.*socket:[[:space:]]*//g')"
  20. # fi
  21. # if [ "${DB_HOST}x" == "x" ]; then
  22. # DB_HOST="localhost"
  23. # fi
  24. # if [ -n "$(which psql 2> /dev/null)" ]; then
  25. # if [ "${DB_PORT}x" == "x" ]; then
  26. # DB_PORT="5432"
  27. # fi
  28. # if [ "${DB_SOCKET}x" == "x" ]; then
  29. # pg_isready -q -h $DB_HOST -p $DB_PORT
  30. # state=$?
  31. # else
  32. # pg_isready -q
  33. # state=$?
  34. # fi
  35. # elif [ -n "$(which mysql 2> /dev/null)" ]; then
  36. # if [ "${DB_PORT}x" == "x" ]; then
  37. # DB_PORT="3306"
  38. # fi
  39. # mysqladmin status -h $DB_HOST -P $DB_PORT
  40. # state=$?
  41. # fi
  42. # # Check error state to ensure database is online
  43. # if [[ $state -gt 0 ]]; then
  44. # echo "!!! ERROR !!!"
  45. # echo "Your database does not seem to be online!"
  46. # echo "Please check your configuration in config/database.yml and ensure the configured database server is online."
  47. # echo "Exiting Zammad package installation / upgrade - try again."
  48. # exit 1
  49. # fi
  50. # remove local files of the packages
  51. if [ -n "$(which zammad 2> /dev/null)" ]; then
  52. PATH=/opt/zammad/bin:/opt/zammad/vendor/bundle/bin:/sbin:/bin:/usr/sbin:/usr/bin:
  53. RAKE_TASKS=$(zammad run rake --tasks | grep "zammad:package:uninstall_all_files")
  54. if [[ x$RAKE_TASKS == 'x' ]]; then
  55. echo "# Code does not yet fit, skipping automatic package uninstall."
  56. echo "... This is not an error and will work during your next upgrade ..."
  57. exit 0
  58. fi
  59. if [ "$(zammad run rails r 'puts Package.count.positive?')" == "true" ] && [ -n "$(which yarn 2> /dev/null)" ] && [ -n "$(which node 2> /dev/null)" ]; then
  60. echo "# Detected custom packages..."
  61. echo "# Remove custom packages files temporarily..."
  62. zammad run rake zammad:package:uninstall_all_files
  63. fi
  64. fi