2021-06-01 12:20:20 +00:00
|
|
|
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
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'
|
2020-02-18 19:51:31 +00:00
|
|
|
task :db_config do # rubocop:disable Rails/RakeEnvironment
|
2018-10-01 17:41:17 +00:00
|
|
|
|
|
|
|
config_dir = Rails.root.join('config')
|
|
|
|
template = config_dir.join('database', 'database.yml')
|
|
|
|
destination = config_dir.join('database.yml')
|
|
|
|
|
2020-08-18 13:01:18 +00:00
|
|
|
raise Errno::ENOENT, "#{template} not found" if !File.exist?(template)
|
2018-10-01 17:41:17 +00:00
|
|
|
|
|
|
|
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] '
|
2020-09-30 09:07:01 +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
|