Refactore config options
This should allow to use databases other than PG and allows to now use the ES
This commit is contained in:
parent
c5751c06f7
commit
2e8af3710b
@ -3,6 +3,7 @@
|
||||
set -e
|
||||
|
||||
: "${AUTOWIZARD_JSON:=''}"
|
||||
: "${ELASTICSEARCH_ENABLE:=true}"
|
||||
: "${ELASTICSEARCH_HOST:=zammad-elasticsearch}"
|
||||
: "${ELASTICSEARCH_PORT:=9200}"
|
||||
: "${ELASTICSEARCH_SCHEMA:=http}"
|
||||
@ -10,12 +11,13 @@ set -e
|
||||
: "${ELASTICSEARCH_SSL_VERIFY:=true}"
|
||||
: "${MEMCACHED_HOST:=zammad-memcached}"
|
||||
: "${MEMCACHED_PORT:=11211}"
|
||||
: "${POSTGRESQL_HOST:=zammad-postgresql}"
|
||||
: "${POSTGRESQL_PORT:=5432}"
|
||||
: "${POSTGRESQL_USER:=zammad}"
|
||||
: "${POSTGRESQL_PASS:=zammad}"
|
||||
: "${POSTGRESQL_DB:=zammad_production}"
|
||||
: "${POSTGRESQL_DB_CREATE:=true}"
|
||||
: "${DB_ADAPTER:=postgresql}"
|
||||
: "${DB_HOST:=zammad-postgresql}"
|
||||
: "${DB_PORT:=5432}"
|
||||
: "${DB_USER:=zammad}"
|
||||
: "${DB_PASS:=zammad}"
|
||||
: "${DB_NAME:=zammad_production}"
|
||||
: "${DB_CREATE:=true}"
|
||||
: "${ZAMMAD_RAILSSERVER_HOST:=zammad-railsserver}"
|
||||
: "${ZAMMAD_RAILSSERVER_PORT:=3000}"
|
||||
: "${ZAMMAD_WEBSOCKET_HOST:=zammad-websocket}"
|
||||
@ -45,7 +47,7 @@ if [ "$1" = 'zammad-init' ]; then
|
||||
cd "${ZAMMAD_DIR}"
|
||||
|
||||
# configure database
|
||||
sed -e "s#.*adapter:.*# adapter: postgresql#g" -e "s#.*database:.*# database: ${POSTGRESQL_DB}#g" -e "s#.*username:.*# username: ${POSTGRESQL_USER}#g" -e "s#.*password:.*# password: ${POSTGRESQL_PASS}\\n host: ${POSTGRESQL_HOST}\\n port: ${POSTGRESQL_PORT}#g" < contrib/packager.io/database.yml.pkgr > config/database.yml
|
||||
sed -e "s#.*adapter:.*# adapter: ${DB_ADAPTER}#g" -e "s#.*database:.*# database: ${DB_NAME}#g" -e "s#.*username:.*# username: ${DB_USER}#g" -e "s#.*password:.*# password: ${DB_PASS}\\n host: ${DB_HOST}\\n port: ${DB_PORT}#g" < contrib/packager.io/database.yml.pkgr > config/database.yml
|
||||
|
||||
# configure memcache
|
||||
sed -i -e "s/.*config.cache_store.*file_store.*cache_file_store.*/ config.cache_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'\\n config.session_store = :dalli_store, '${MEMCACHED_HOST}:${MEMCACHED_PORT}'/" config/application.rb
|
||||
@ -53,7 +55,7 @@ if [ "$1" = 'zammad-init' ]; then
|
||||
# check if database exists / update to new version
|
||||
echo "initialising / updating database..."
|
||||
if ! (bundle exec rails r 'puts User.any?' 2> /dev/null | grep -q true); then
|
||||
if [ "${POSTGRESQL_DB_CREATE}" == "true" ]; then
|
||||
if [ "${DB_CREATE}" == "true" ]; then
|
||||
bundle exec rake db:create
|
||||
fi
|
||||
bundle exec rake db:migrate
|
||||
@ -67,31 +69,33 @@ if [ "$1" = 'zammad-init' ]; then
|
||||
bundle exec rake db:migrate
|
||||
fi
|
||||
|
||||
# es config
|
||||
echo "changing settings..."
|
||||
bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')"
|
||||
if [ "${ELASTICSEARCH_ENABLE}" = "true" ]; then
|
||||
# es config
|
||||
echo "changing settings..."
|
||||
bundle exec rails r "Setting.set('es_url', '${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}')"
|
||||
|
||||
bundle exec rails r "Setting.set('es_index', '${ELASTICSEARCH_NAMESPACE}')"
|
||||
bundle exec rails r "Setting.set('es_index', '${ELASTICSEARCH_NAMESPACE}')"
|
||||
|
||||
if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASS}" ]; then
|
||||
bundle exec rails r "Setting.set('es_user', \"${ELASTICSEARCH_USER}\")"
|
||||
bundle exec rails r "Setting.set('es_password', \"${ELASTICSEARCH_PASS}\")"
|
||||
fi
|
||||
if [ -n "${ELASTICSEARCH_USER}" ] && [ -n "${ELASTICSEARCH_PASS}" ]; then
|
||||
bundle exec rails r "Setting.set('es_user', \"${ELASTICSEARCH_USER}\")"
|
||||
bundle exec rails r "Setting.set('es_password', \"${ELASTICSEARCH_PASS}\")"
|
||||
fi
|
||||
|
||||
until (echo > /dev/tcp/${ELASTICSEARCH_HOST}/${ELASTICSEARCH_PORT}) &> /dev/null; do
|
||||
echo "zammad railsserver waiting for elasticsearch server to be ready..."
|
||||
sleep 5
|
||||
done
|
||||
until (echo > /dev/tcp/${ELASTICSEARCH_HOST}/${ELASTICSEARCH_PORT}) &> /dev/null; do
|
||||
echo "zammad railsserver waiting for elasticsearch server to be ready..."
|
||||
sleep 5
|
||||
done
|
||||
|
||||
if [ "${ELASTICSEARCH_SSL_VERIFY}" == "false" ]; then
|
||||
SSL_SKIP_VERIFY="-k"
|
||||
else
|
||||
SSL_SKIP_VERIFY=""
|
||||
fi
|
||||
|
||||
if ! curl -s ${SSL_SKIP_VERIFY} ${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices | grep -q zammad; then
|
||||
echo "rebuilding es searchindex..."
|
||||
bundle exec rake searchindex:rebuild
|
||||
if [ "${ELASTICSEARCH_SSL_VERIFY}" == "false" ]; then
|
||||
SSL_SKIP_VERIFY="-k"
|
||||
else
|
||||
SSL_SKIP_VERIFY=""
|
||||
fi
|
||||
|
||||
if ! curl -s ${SSL_SKIP_VERIFY} ${ELASTICSEARCH_SCHEMA}://${ELASTICSEARCH_HOST}:${ELASTICSEARCH_PORT}/_cat/indices | grep -q zammad; then
|
||||
echo "rebuilding es searchindex..."
|
||||
bundle exec rake searchindex:rebuild
|
||||
fi
|
||||
fi
|
||||
|
||||
# chown everything to zammad user
|
||||
|
Loading…
Reference in New Issue
Block a user