#!/bin/bash ROOT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd ) set -e run() { eval $@ } # Enter the root directory cd $ROOT_DIR # Run the right command case "$1" in web-server) run "bundle exec puma -C config/puma.rb" ;; smtp-server) run "bundle exec rake postal:smtp_server" ;; worker) run "bundle exec ruby script/worker.rb" ;; cron) run "bundle exec rake postal:cron" ;; requeuer) run "bundle exec rake postal:requeuer" ;; initialize) echo 'Initializing database' run "bundle exec rake db:create db:schema:load db:seed" ;; upgrade) echo 'Migrating database' run "bundle exec rake db:migrate" ;; console) run "bundle exec rails console" ;; default-dkim-record) run "bundle exec ruby script/default_dkim_record.rb" ;; make-user) run "bundle exec ruby script/make_user.rb" ;; test-app-smtp) run "bundle exec ruby script/test_app_smtp.rb $2" ;; version) run "bundle exec ruby script/version.rb" ;; *) echo "Usage: postal [command]" echo echo "Server components:" echo echo -e " * \e[35mweb-server\e[0m - run the web server" echo -e " * \e[35msmtp-server\e[0m - run the SMTP server" echo -e " * \e[35mworker\e[0m - run a worker" echo -e " * \e[35mcron\e[0m - run the cron process" echo -e " * \e[35mrequeuer\e[0m - run the message requeuer" echo echo "Setup/upgrade tools:" echo echo -e " * \e[32minitialize\e[0m - create and load the DB schema" echo -e " * \e[32mupgrade\e[0m - upgrade the DB schema" echo echo "Other tools:" echo echo -e " * \e[34mversion\e[0m - show the current Postal version" echo -e " * \e[34mmake-user\e[0m - create a new global admin user" echo -e " * \e[34mdefault-dkim-record\e[0m - display the default DKIM record" echo -e " * \e[34mconsole\e[0m - open an interactive console" echo -e " * \e[34mtest-app-smtp\e[0m - send a test message through Postal" echo esac