2016-12-17 11:10:51 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2017-11-19 18:04:24 +00:00
|
|
|
set -e
|
|
|
|
|
2017-10-02 21:41:16 +00:00
|
|
|
# zammad-railsserver
|
2017-01-12 13:14:25 +00:00
|
|
|
if [ "$1" = 'zammad-railsserver' ]; then
|
2017-03-08 18:37:05 +00:00
|
|
|
# wait for postgres process coming up on zammad-postgresql
|
2017-03-10 08:48:09 +00:00
|
|
|
until (echo > /dev/tcp/zammad-postgresql/5432) &> /dev/null; do
|
2017-04-23 22:25:43 +00:00
|
|
|
echo "zammad railsserver waiting for postgresql server to be ready..."
|
2017-03-08 18:37:05 +00:00
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
2017-04-23 22:25:43 +00:00
|
|
|
echo "railsserver can access postgresql server now..."
|
|
|
|
|
2017-09-15 07:24:27 +00:00
|
|
|
rsync -a --delete --exclude 'storage/fs/*' ${ZAMMAD_TMP_DIR}/ ${ZAMMAD_DIR}
|
2017-09-13 19:52:27 +00:00
|
|
|
|
2017-03-08 18:37:05 +00:00
|
|
|
cd ${ZAMMAD_DIR}
|
2017-07-22 13:14:20 +00:00
|
|
|
|
|
|
|
# update zammad
|
|
|
|
gem update bundler
|
|
|
|
bundle install
|
|
|
|
|
|
|
|
# db mirgrate
|
2017-11-21 15:19:57 +00:00
|
|
|
set +e
|
2017-05-12 11:21:53 +00:00
|
|
|
bundle exec rake db:migrate &> /dev/null
|
2017-03-08 18:37:05 +00:00
|
|
|
|
|
|
|
if [ $? != 0 ]; then
|
|
|
|
echo "creating db & searchindex..."
|
2017-11-21 15:19:57 +00:00
|
|
|
set -e
|
2017-03-08 18:37:05 +00:00
|
|
|
bundle exec rake db:create
|
|
|
|
bundle exec rake db:migrate
|
|
|
|
bundle exec rake db:seed
|
|
|
|
fi
|
|
|
|
|
2017-11-21 15:19:57 +00:00
|
|
|
set -e
|
|
|
|
|
2017-07-22 13:14:20 +00:00
|
|
|
# es config
|
|
|
|
bundle exec rails r "Setting.set('es_url', 'http://zammad-elasticsearch:9200')"
|
|
|
|
bundle exec rake searchindex:rebuild
|
|
|
|
|
|
|
|
chown -R ${ZAMMAD_USER}:${ZAMMAD_USER} ${ZAMMAD_DIR}
|
|
|
|
|
2017-03-08 18:37:05 +00:00
|
|
|
# run zammad
|
|
|
|
echo "starting zammad..."
|
|
|
|
echo "zammad will be accessable on http://localhost in some seconds"
|
|
|
|
|
|
|
|
if [ "${RAILS_SERVER}" == "puma" ]; then
|
2017-07-22 13:14:20 +00:00
|
|
|
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec puma -b tcp://0.0.0.0:3000 -e ${RAILS_ENV}
|
2017-05-12 09:21:54 +00:00
|
|
|
elif [ "${RAILS_SERVER}" == "unicorn" ]; then
|
2017-07-22 13:14:20 +00:00
|
|
|
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec unicorn -p 3000 -c config/unicorn.rb -E ${RAILS_ENV}
|
2017-03-08 18:37:05 +00:00
|
|
|
fi
|
2017-10-02 21:41:16 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# zammad-scheduler
|
|
|
|
if [ "$1" = 'zammad-scheduler' ]; then
|
|
|
|
# wait for zammad process coming up
|
|
|
|
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
|
|
|
|
echo "scheduler waiting for zammads railsserver to be ready..."
|
|
|
|
sleep 2
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "scheduler can access raillsserver now..."
|
2016-12-17 11:10:51 +00:00
|
|
|
|
2017-10-02 21:41:16 +00:00
|
|
|
# start scheduler
|
|
|
|
cd ${ZAMMAD_DIR}
|
|
|
|
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/scheduler.rb run
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# zammad-websocket
|
|
|
|
if [ "$1" = 'zammad-websocket' ]; then
|
|
|
|
# wait for zammad process coming up
|
|
|
|
until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do
|
|
|
|
echo "websocket server waiting for zammads railsserver to be ready..."
|
|
|
|
sleep 5
|
|
|
|
done
|
|
|
|
|
|
|
|
echo "websocket server can access raillsserver now..."
|
|
|
|
|
|
|
|
cd ${ZAMMAD_DIR}
|
|
|
|
exec gosu ${ZAMMAD_USER}:${ZAMMAD_USER} bundle exec script/websocket-server.rb -b 0.0.0.0 start
|
2016-12-17 11:10:51 +00:00
|
|
|
fi
|