2019-02-15 15:52:40 +00:00
|
|
|
#!/usr/bin/env bash
|
2019-02-15 15:11:49 +00:00
|
|
|
set -e
|
|
|
|
|
|
|
|
# install dependencies
|
2021-03-03 19:28:03 +00:00
|
|
|
if [ "$1" = 'builder' ]; then
|
2021-10-05 19:25:26 +00:00
|
|
|
PACKAGES="build-essential curl git libimlib2-dev libpq-dev nodejs shared-mime-info"
|
2021-03-03 19:28:03 +00:00
|
|
|
elif [ "$1" = 'runner' ]; then
|
2020-02-18 20:01:11 +00:00
|
|
|
PACKAGES="curl libimlib2 libpq5 nginx rsync"
|
2019-02-15 15:11:49 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
apt-get update
|
|
|
|
apt-get upgrade -y
|
2020-02-26 23:33:46 +00:00
|
|
|
# shellcheck disable=SC2086
|
2019-02-15 15:11:49 +00:00
|
|
|
apt-get install -y --no-install-recommends ${PACKAGES}
|
|
|
|
rm -rf /var/lib/apt/lists/*
|
|
|
|
|
|
|
|
# install zammad
|
|
|
|
groupadd -g 1000 "${ZAMMAD_USER}"
|
|
|
|
useradd -M -d "${ZAMMAD_DIR}" -s /bin/bash -u 1000 -g 1000 "${ZAMMAD_USER}"
|
|
|
|
|
2021-03-03 19:28:03 +00:00
|
|
|
if [ "$1" = 'builder' ]; then
|
2019-02-15 15:11:49 +00:00
|
|
|
cd "$(dirname "${ZAMMAD_TMP_DIR}")"
|
|
|
|
curl -s -J -L -O "${TAR_GZ_URL}"
|
|
|
|
tar -xzf zammad-"${GIT_BRANCH}".tar.gz
|
|
|
|
rm zammad-"${GIT_BRANCH}".tar.gz
|
|
|
|
cd "${ZAMMAD_TMP_DIR}"
|
2021-10-20 11:35:09 +00:00
|
|
|
bundle config set without 'test development mysql'
|
|
|
|
bundle install
|
2019-02-15 15:11:49 +00:00
|
|
|
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
|
2019-07-16 10:24:49 +00:00
|
|
|
sed -i "/require 'rails\/all'/a require\ 'nulldb'" config/application.rb
|
2019-02-15 15:11:49 +00:00
|
|
|
sed -i 's/.*scheduler_\(err\|out\).log.*//g' script/scheduler.rb
|
2019-07-16 10:24:49 +00:00
|
|
|
touch db/schema.rb
|
2019-02-15 15:11:49 +00:00
|
|
|
bundle exec rake assets:precompile
|
|
|
|
rm -r tmp/cache
|
2021-10-20 11:35:09 +00:00
|
|
|
script/build/cleanup.sh
|
2019-02-15 15:11:49 +00:00
|
|
|
chown -R "${ZAMMAD_USER}":"${ZAMMAD_USER}" "${ZAMMAD_TMP_DIR}"
|
|
|
|
fi
|
2021-03-03 19:28:03 +00:00
|
|
|
|
2021-03-03 19:53:51 +00:00
|
|
|
# set nginx file permissions and settings
|
2021-03-03 19:28:03 +00:00
|
|
|
if [ "$1" = 'runner' ]; then
|
2021-03-03 19:53:51 +00:00
|
|
|
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
|
2021-03-03 19:28:03 +00:00
|
|
|
mkdir -p "${ZAMMAD_DIR}" /var/log/nginx
|
|
|
|
chown -R "${ZAMMAD_USER}":"${ZAMMAD_USER}" /etc/nginx "${ZAMMAD_DIR}" /var/lib/nginx /var/log/nginx
|
|
|
|
fi
|