parent
7d6a94d358
commit
53db3e7711
@ -1,3 +1,4 @@ |
||||
web: bundle exec unicorn --host ${HOST:="127.0.0.1"} --port ${PORT:="8080"} --env ${RAILS_ENV:="development"} |
||||
worker: bundle exec rake jobs:work |
||||
backup: ./packaging/scripts/backup |
||||
check: ./packaging/scripts/check |
||||
|
@ -0,0 +1,67 @@ |
||||
#!/bin/bash |
||||
|
||||
set -e |
||||
|
||||
log_ok() { |
||||
echo -e "\e[32m[ok]\e[0m $1" |
||||
} |
||||
|
||||
log_ko() { |
||||
echo -e "\e[31m[ko]\e[0m $1" |
||||
} |
||||
|
||||
tmpfile=$(mktemp) |
||||
|
||||
if [ -z "$DATABASE_URL" ]; then |
||||
log_ko "DATABASE_URL environment variable can't be found. Database connection failed." |
||||
else |
||||
|
||||
database=$(ruby -ruri -e 'puts URI(ENV["DATABASE_URL"]).path[1..-1]') |
||||
|
||||
ruby -ruri -e ' |
||||
uri = URI(ENV["DATABASE_URL"]) |
||||
config=<<CONFIG |
||||
[client] |
||||
password="#{uri.password}" |
||||
user="#{uri.user}" |
||||
host="#{uri.host}" |
||||
port="#{uri.port}" |
||||
CONFIG |
||||
puts config' > ${tmpfile} |
||||
|
||||
if mysql --defaults-file=${tmpfile} -D "${database}" -e "select count(*) from users;" &>/dev/null ; then |
||||
log_ok "MySQL configuration is working" |
||||
else |
||||
log_ko "MySQL connection is NOT working" |
||||
fi |
||||
|
||||
rm -f $tmpfile |
||||
fi |
||||
|
||||
if /etc/init.d/apache2 status &>/dev/null; then |
||||
log_ok "Apache2 is running" |
||||
else |
||||
log_ko "Apache2 is NOT running" |
||||
fi |
||||
|
||||
if ps -u openproject -f | grep -q "unicorn worker" ; then |
||||
log_ok "openproject server is running" |
||||
else |
||||
log_ko "openproject server is NOT running" |
||||
fi |
||||
|
||||
if ps -u openproject -f | grep -q "rake jobs:work" ; then |
||||
log_ok "openproject background job worker is running" |
||||
else |
||||
log_ko "openproject background job worker is NOT running" |
||||
fi |
||||
|
||||
if [ -z "$ADMIN_EMAIL" ]; then |
||||
log_ko "no ADMIN_EMAIL set. Can't test email settings." |
||||
else |
||||
if $(pwd)/packaging/scripts/send-test-email ; then |
||||
log_ok "test email sent to ${ADMIN_EMAIL}" |
||||
else |
||||
log_ko "unable to send test email to ${ADMIN_EMAIL}" |
||||
fi |
||||
fi |
@ -0,0 +1,42 @@ |
||||
#!/usr/bin/env ruby |
||||
|
||||
require 'net/smtp' |
||||
require 'time' |
||||
require 'securerandom' |
||||
require 'tempfile' |
||||
|
||||
admin_email = ENV.fetch('ADMIN_EMAIL') { fail "no ADMIN_EMAIL set" } |
||||
smtp_domain = ENV.fetch('SMTP_DOMAIN') { "example.net" } |
||||
from = "no-reply@#{smtp_domain}" |
||||
delivery_method = ENV.fetch('EMAIL_DELIVERY_METHOD') { "sendmail" } |
||||
|
||||
msgstr = <<END_OF_MESSAGE |
||||
From: OpenProject <#{from}> |
||||
To: #{admin_email} |
||||
Subject: Test message |
||||
Date: #{Time.now.httpdate} |
||||
Message-Id: <#{SecureRandom.hex}@#{smtp_domain}> |
||||
|
||||
This is a test message to verify your OpenProject settings. |
||||
If you see this, this means OpenProject email settings are working properly. |
||||
END_OF_MESSAGE |
||||
|
||||
if delivery_method == "sendmail" |
||||
puts "sending test email using sendmail..." |
||||
tmpfile = Tempfile.new("mail-test") |
||||
File.open(tmpfile.path, "w+") {|f| f << msgstr} |
||||
system "cat #{tmpfile.path} | sendmail -i -t" |
||||
else |
||||
puts "sending test email using SMTP..." |
||||
Net::SMTP.start( |
||||
ENV.fetch('SMTP_HOST'), |
||||
ENV.fetch('SMTP_PORT'), |
||||
ENV.fetch('SMTP_DOMAIN'), |
||||
ENV.fetch('SMTP_USERNAME'), |
||||
ENV.fetch('SMTP_PASSWORD'), |
||||
:login |
||||
) do |smtp| |
||||
smtp.send_message msgstr, from, admin_email |
||||
end |
||||
end |
||||
|
Loading…
Reference in new issue