From 9aa8a7540d332f80abd37ee91f71b2f368b27ec7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Tue, 21 Nov 2017 16:19:57 +0100 Subject: [PATCH 1/2] deactivated set -e for db check --- containers/zammad-postgresql/backup.sh | 2 ++ containers/zammad/docker-entrypoint.sh | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/containers/zammad-postgresql/backup.sh b/containers/zammad-postgresql/backup.sh index 62e47d4..03a942b 100644 --- a/containers/zammad-postgresql/backup.sh +++ b/containers/zammad-postgresql/backup.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + if [ "$1" = 'zammad-backup' ]; then # wait for zammad process coming up until (echo > /dev/tcp/zammad-railsserver/3000) &> /dev/null; do diff --git a/containers/zammad/docker-entrypoint.sh b/containers/zammad/docker-entrypoint.sh index f3ea993..9a5d00c 100644 --- a/containers/zammad/docker-entrypoint.sh +++ b/containers/zammad/docker-entrypoint.sh @@ -21,15 +21,19 @@ if [ "$1" = 'zammad-railsserver' ]; then bundle install # db mirgrate + set +e bundle exec rake db:migrate &> /dev/null if [ $? != 0 ]; then echo "creating db & searchindex..." + set -e bundle exec rake db:create bundle exec rake db:migrate bundle exec rake db:seed fi + set -e + # es config bundle exec rails r "Setting.set('es_url', 'http://zammad-elasticsearch:9200')" bundle exec rake searchindex:rebuild From c93f1422b1cc9e883314311385b5e28c4aa54166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Bauer?= Date: Tue, 21 Nov 2017 16:24:57 +0100 Subject: [PATCH 2/2] better error handling --- containers/zammad/docker-entrypoint.sh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/containers/zammad/docker-entrypoint.sh b/containers/zammad/docker-entrypoint.sh index 9a5d00c..23324b6 100644 --- a/containers/zammad/docker-entrypoint.sh +++ b/containers/zammad/docker-entrypoint.sh @@ -23,17 +23,16 @@ if [ "$1" = 'zammad-railsserver' ]; then # db mirgrate set +e bundle exec rake db:migrate &> /dev/null + DB_CHECK="$?" + set -e - if [ $? != 0 ]; then + if [ "${DB_CHECK}" != "0" ]; then echo "creating db & searchindex..." - set -e bundle exec rake db:create bundle exec rake db:migrate bundle exec rake db:seed fi - set -e - # es config bundle exec rails r "Setting.set('es_url', 'http://zammad-elasticsearch:9200')" bundle exec rake searchindex:rebuild