zammad-docker-compose/docker-entrypoint.sh

54 lines
1.2 KiB
Bash
Raw Normal View History

2016-12-17 11:10:51 +00:00
#!/bin/bash
2016-12-19 20:51:36 +00:00
ZAMMAD_DIR="/home/zammad"
GIT_URL="https://github.com/zammad/zammad.git"
GIT_BRANCH="develop"
#GIT_URL="https://github.com/monotek/zammad.git"
#GIT_BRANCH="unicorn"
RAILS_SERVER="puma"
RAILS_ENV="production"
2016-12-19 21:29:04 +00:00
DEBUG="no"
2016-12-19 20:26:04 +00:00
2016-12-20 12:51:56 +00:00
if [ "$1" = 'zammad' ]; then
2016-12-17 11:10:51 +00:00
2016-12-20 12:51:56 +00:00
export RAILS_ENV=${RAILS_ENV}
2016-12-19 20:26:04 +00:00
cd ${ZAMMAD_DIR}
rake db:migrate &> /dev/null
2016-12-19 20:26:04 +00:00
if [ $? != 0 ]; then
echo "creating db, assets, searchindex..."
2016-12-17 11:10:51 +00:00
rake db:create
rake db:migrate
rake db:seed
rake assets:precompile
rails r "Setting.set('es_url', 'http://elasticsearch:9200')"
2016-12-21 02:31:31 +00:00
rake searchindex:rebuild
2016-12-17 11:10:51 +00:00
fi
# delete logs & pids
2016-12-17 11:10:51 +00:00
rm ${ZAMMAD_DIR}/log/*
rm ${ZAMMAD_DIR}/tmp/pids/*
# run zammad
echo "starting zammad..."
2016-12-17 12:23:29 +00:00
echo "zammad will be accessable on http://localhost in some seconds"
2016-12-19 20:26:04 +00:00
bundle exec script/websocket-server.rb -b 0.0.0.0 start &
bundle exec script/scheduler.rb start &
2016-12-19 20:39:15 +00:00
2016-12-19 20:26:04 +00:00
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
bundle exec unicorn -p 3000 -c config/unicorn.rb -E ${RAILS_ENV}
2016-12-19 20:26:04 +00:00
fi
2016-12-17 11:10:51 +00:00
if [ "${DEBUG}" == "yes" ]; then
# keepalive if error
while true; do
echo "debugging..."
sleep 600
done
fi
fi