diff --git a/scripts/start.sh b/scripts/start.sh index 2a01ed0..79383d9 100755 --- a/scripts/start.sh +++ b/scripts/start.sh @@ -29,13 +29,19 @@ sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/username.*/username: $RABBITMQ_DEFAULT_U sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/password.*/password: $RABBITMQ_DEFAULT_PASS/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml sed -i -e '/rabbitmq:/!b' -e ':a' -e "s/vhost.*/vhost: \/$RABBITMQ_DEFAULT_VHOST/;t trail" -e 'n;ba' -e ':trail' -e 'n;btrail' /opt/postal/config/postal.yml +## Clean Up +rm -rf /opt/postal/tmp/pids/* + ## Initialize DB echo "== Waiting for MySQL to start up ==" while ! mysqladmin ping -h mysql --silent; do sleep 1 done -/opt/postal/bin/postal upgrade - +if [[ $(mysql -h mysql -uroot -p$MYSQL_ROOT_PASSWORD -s --skip-column-names -e "SELECT COUNT(DISTINCT table_name) FROM information_schema.columns WHERE table_schema = 'postal'") == 0 ]]; then + /opt/postal/bin/postal initialize +else + /opt/postal/bin/postal upgrade +fi ## Run /opt/postal/bin/postal run