2016-12-17 11:10:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-01-12 13:14:25 +00:00
|
|
|
if [ "$1" = 'zammad-railsserver' ]; then
|
2016-12-17 11:10:51 +00:00
|
|
|
|
2017-03-08 18:37:05 +00:00
|
|
|
# wait for postgres process coming up on zammad-postgresql
|
|
|
|
until echo > /dev/tcp/zammad-postgresql/5432; do
|
|
|
|
echo "waiting for postgres to be ready..."
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
|
|
|
cd ${ZAMMAD_DIR}
|
|
|
|
bundle exec rake db:migrate &> /dev/null
|
|
|
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "creating db & searchindex..."
|
|
|
|
bundle exec rake db:create
|
|
|
|
bundle exec rake db:migrate
|
|
|
|
bundle exec rake db:seed
|
2017-03-08 19:15:02 +00:00
|
|
|
bundle exec rails r "Setting.set('es_url', 'http://zammad-elasticsearch:9200')"
|
2017-03-08 18:37:05 +00:00
|
|
|
bundle exec rake searchindex:rebuild
|
|
|
|
fi
|
|
|
|
|
|
|
|
# delete logs
|
|
|
|
find ${ZAMMAD_DIR}/log -iname *.log -exec rm {} \;
|
|
|
|
|
|
|
|
# run zammad
|
|
|
|
echo "starting zammad..."
|
|
|
|
echo "zammad will be accessable on http://localhost in some seconds"
|
|
|
|
|
|
|
|
if [ "${RAILS_SERVER}" == "puma" ]; then
|
|
|
|
bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV}
|
2016-12-19 20:26:04 +00:00
|
|
|
elif [ "${RAILS_SERVER}" == "unicorn" ]; then
|
2017-03-08 18:37:05 +00:00
|
|
|
bundle exec unicorn -p 3000 -c config/unicorn.rb -E ${RAILS_ENV}
|
|
|
|
fi
|
2016-12-17 11:10:51 +00:00
|
|
|
|
|
|
|
fi
|