zammad-docker-compose/docker-entrypoint.sh

73 lines
1.8 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-20 12:52:21 +00:00
FRESH_INSTALL="no"
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
2016-12-20 12:51:56 +00:00
shopt -s dotglob
2016-12-19 20:26:04 +00:00
2016-12-20 12:51:56 +00:00
if [ "${FRESH_INSTALL}" == "yes" ]; then
echo "fresh install requested. deleting everything in ${ZAMMAD_DIR}"
rm -rf ${ZAMMAD_DIR}/*
fi
2016-12-17 11:10:51 +00:00
# get zammad
if [ -f ${ZAMMAD_DIR}/config/database.yml ]; then
echo "updating zammad..."
cd ${ZAMMAD_DIR}
git pull
bundle update
rake db:migrate
else
echo "installing zammad..."
cd /tmp
2016-12-19 20:26:04 +00:00
git clone ${GIT_URL}
2016-12-17 11:10:51 +00:00
mv -f /tmp/zammad/* ${ZAMMAD_DIR}/
cd ${ZAMMAD_DIR}
2016-12-19 20:26:04 +00:00
git checkout ${GIT_BRANCH}
2016-12-17 11:10:51 +00:00
bundle install --without test development
sed -e 's#.*username:.*# username: postgres#g' -e 's#.*password:.*# password: \n host: postgresql\n#g' < config/database.yml.pkgr > config/database.yml
rake db:drop
rake db:create
rake db:migrate
rake db:seed
rake assets:precompile
rails r "Setting.set('es_url', 'http://elasticsearch:9200')"
fi
# delte logs & pids
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
2016-12-20 11:50:46 +00:00
bundle exec puma -p 3000 -b tcp://0.0.0.0
2016-12-19 20:26:04 +00:00
elif [ "${RAILS_SERVER}" == "unicorn" ]; then
bundle exec unicorn -p 3000 -c config/unicorn.rb
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