2018-10-01 17:41:17 +00:00
|
|
|
namespace :zammad do
|
|
|
|
|
|
|
|
namespace :setup do
|
|
|
|
|
|
|
|
desc 'Copies the database config template file to config/database.yml'
|
|
|
|
task :db_config do
|
|
|
|
|
|
|
|
config_dir = Rails.root.join('config')
|
|
|
|
template = config_dir.join('database', 'database.yml')
|
|
|
|
destination = config_dir.join('database.yml')
|
|
|
|
|
|
|
|
raise Errno::ENOENT, "#{template} not found" unless File.exist?(template)
|
|
|
|
|
|
|
|
if File.exist?(destination)
|
|
|
|
next if FileUtils.identical?(template, destination)
|
2018-10-09 06:17:41 +00:00
|
|
|
|
2018-10-01 17:41:17 +00:00
|
|
|
printf 'config/database.yml: File exists. Overwrite? [y/N] '
|
2019-09-05 13:51:13 +00:00
|
|
|
next if !STDIN.gets.chomp.casecmp('y').zero?
|
2018-10-01 17:41:17 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
FileUtils.cp(template, destination)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|