setup.sh 1.4 KB

12345678910111213141516171819202122232425262728293031323334
  1. #!/usr/bin/env bash
  2. set -e
  3. if [ "$1" = 'builder' ]; then
  4. PACKAGES="build-essential curl git libimlib2-dev libpq-dev shared-mime-info"
  5. elif [ "$1" = 'runner' ]; then
  6. PACKAGES="curl libimlib2 libpq5 nginx gnupg"
  7. fi
  8. apt-get update
  9. apt-get upgrade -y
  10. # shellcheck disable=SC2086
  11. apt-get install -y --no-install-recommends ${PACKAGES}
  12. rm -rf /var/lib/apt/lists/*
  13. if [ "$1" = 'builder' ]; then
  14. cd "${ZAMMAD_DIR}"
  15. bundle config set without 'test development mysql'
  16. bundle install
  17. sed -e 's#.*adapter: postgresql# adapter: nulldb#g' -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: zammad-postgresql\n#g' < contrib/packager.io/database.yml.pkgr > config/database.yml
  18. sed -i "/require 'rails\/all'/a require\ 'nulldb'" config/application.rb
  19. touch db/schema.rb
  20. ZAMMAD_SAFE_MODE=1 bundle exec rake assets:precompile # Don't require Redis.
  21. rm -r tmp/cache
  22. script/build/cleanup.sh
  23. fi
  24. if [ "$1" = 'runner' ]; then
  25. groupadd -g 1000 "${ZAMMAD_USER}"
  26. useradd -M -d "${ZAMMAD_DIR}" -s /bin/bash -u 1000 -g 1000 "${ZAMMAD_USER}"
  27. sed -i -e "s#user www-data;##g" -e 's#/var/log/nginx/\(access\|error\).log#/dev/stdout#g' -e 's#pid /run/nginx.pid;#pid /tmp/nginx.pid;#g' /etc/nginx/nginx.conf
  28. mkdir -p "${ZAMMAD_DIR}" /var/log/nginx
  29. chown -R "${ZAMMAD_USER}":"${ZAMMAD_USER}" /etc/nginx /var/lib/nginx /var/log/nginx "${ZAMMAD_DIR}"
  30. fi