Chatwoot/docker/entrypoints/helpers/pg_database_url.rb
Pascal Jufer c37966744f
fix: Fix and rename pg_database_url.sh helper script (#2747)
- Fix and rename pg_database_url helper script
- Use single-quote and remove trailing whitespace
2021-08-03 22:56:55 +05:30

10 lines
399 B
Ruby
Executable file

#!/usr/bin/env ruby
require 'uri'
# Let DATABASE_URL env take presedence over individual connection params.
if !ENV['DATABASE_URL'].nil? && ENV['DATABASE_URL'] != ''
uri = URI(ENV['DATABASE_URL'])
puts "export POSTGRES_HOST=#{uri.host} POSTGRES_PORT=#{uri.port} POSTGRES_USERNAME=#{uri.user}"
elsif ENV['POSTGRES_PORT'].nil? || ENV['POSTGRES_PORT'] == ''
puts 'export POSTGRES_PORT=5432'
end