setup.sh 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/usr/bin/env bash
  2. set -e
  3. apt-get update
  4. apt-get upgrade -y
  5. if [ "$1" = 'builder' ]; then
  6. PACKAGES="build-essential curl git libimlib2-dev libpq-dev"
  7. elif [ "$1" = 'runner' ]; then
  8. # Add official PostgreSQL apt repository to not depend on Debian's version.
  9. # https://www.postgresql.org/download/linux/debian/
  10. apt-get install -y postgresql-common
  11. /usr/share/postgresql-common/pgdg/apt.postgresql.org.sh -y
  12. PACKAGES="curl libimlib2 libpq5 nginx gnupg postgresql-client-17"
  13. fi
  14. # shellcheck disable=SC2086
  15. apt-get install -y --no-install-recommends ${PACKAGES}
  16. rm -rf /var/lib/apt/lists/*
  17. if [ "$1" = 'builder' ]; then
  18. cd "${ZAMMAD_DIR}"
  19. bundle config set --local without 'test development mysql'
  20. # Don't use the 'deployment' switch here as it would require always using 'bundle exec'
  21. # to invoke commands like rails.
  22. bundle config set --local frozen 'true'
  23. bundle install
  24. touch db/schema.rb
  25. ZAMMAD_SAFE_MODE=1 DATABASE_URL=postgresql://zammad:/zammad bundle exec rake assets:precompile # Don't require Redis or Postgres.
  26. script/build/cleanup.sh
  27. fi
  28. if [ "$1" = 'runner' ]; then
  29. groupadd -g 1000 "${ZAMMAD_USER}"
  30. useradd -M -d "${ZAMMAD_DIR}" -s /bin/bash -u 1000 -g 1000 "${ZAMMAD_USER}"
  31. 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
  32. mkdir -p "${ZAMMAD_DIR}" /var/log/nginx
  33. mkdir -p "${ZAMMAD_DIR}/storage" # Pre-create the storage folder to avoid mount permission issues (see https://github.com/zammad/zammad/issues/5412).
  34. chown -R "${ZAMMAD_USER}":"${ZAMMAD_USER}" /etc/nginx /var/lib/nginx /var/log/nginx "${ZAMMAD_DIR}"
  35. fi