From 01def1679172ebcf2ffddc15ba365916d95e4acf Mon Sep 17 00:00:00 2001 From: Alex Legler Date: Thu, 16 Sep 2010 22:11:43 +0200 Subject: Adding Capistrano infrastructure --- script/config_init | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 script/config_init (limited to 'script') diff --git a/script/config_init b/script/config_init new file mode 100755 index 0000000..c4d81e2 --- /dev/null +++ b/script/config_init @@ -0,0 +1,44 @@ +#!/usr/bin/env ruby +PWD = File.dirname(__FILE__) + +begin + require 'yaml' + + puts "Initializing GLSAMaker 2 configuration in '#{File.expand_path(PWD + '/../')}'..." + + File.umask 0077 + + puts "Reading configuration..." + require PWD + '/../tmp/deploy.private.rb' + + Dir.chdir(File.join(PWD, '../config')) do + puts "Setting database.yml..." + y = YAML.load(open('database.yml.mysql')) + + if DB_CONN == :tcp + y['production']['host'] = DB_HOST + y['production']['port'] = DB_PORT + elsif DB_CONN == :sock + y['production']['socket'] = DB_SOCK + end + + y['production']['username'] = DB_USER + y['production']['password'] = DB_PASS + y['production']['database'] = DB_DB + + File.open('database.yml', 'w') {|f| YAML.dump(y, f) } + + puts "Creating initializers/glsamaker.rb..." + File.open('initializers/glsamaker.rb', 'w') do |f| + f.write INITIALIZER + end + end + + puts "Removing deploy configuration" + File.unlink(PWD + '/../tmp/deploy.private.rb') + + puts 'all done!' +rescue Exception => e + $stderr.puts "!! Failed: #{e.message}" + exit 1 +end -- cgit v1.2.3-65-gdbad