preinstall.sh 1.2 KB

12345678910111213141516171819202122232425262728293031
  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. # remove local files of the packages
  13. if [ -n "$(which zammad 2> /dev/null)" ]; then
  14. PATH=/opt/zammad/bin:/opt/zammad/vendor/bundle/bin:/sbin:/bin:/usr/sbin:/usr/bin:
  15. RAKE_TASKS=$(zammad run rake --tasks | grep "zammad:package:uninstall_all_files")
  16. if [[ x$RAKE_TASKS == 'x' ]]; then
  17. echo "# Code does not yet fit, skipping automatic package uninstall."
  18. echo "... This is not an error and will work during your next upgrade ..."
  19. exit 0
  20. fi
  21. if [ "$(zammad run rails r 'puts Package.count.positive?')" == "true" ] && [ -n "$(which yarn 2> /dev/null)" ] && [ -n "$(which node 2> /dev/null)" ]; then
  22. echo "# Detected custom packages..."
  23. echo "# Remove custom packages files temporarily..."
  24. zammad run rake zammad:package:uninstall_all_files
  25. fi
  26. fi