badger-rails 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest CHANGED
@@ -4,6 +4,7 @@ LICENSING
4
4
  Manifest
5
5
  README.md
6
6
  Rakefile
7
+ badger-rails.gemspec
7
8
  bin/badger
8
9
  lib/badger/Capfile
9
10
  lib/badger/config/deploy.rb
data/README.md CHANGED
@@ -3,6 +3,8 @@
3
3
  Allows for deployment of Rails 3 project to a CentOS 6+ Red Hat 6+ or Ubuntu Server running Mysql and Nginx.<br>
4
4
  Badger Rails deploys to a Cent Os server by Capistrano for ease of use and Bash for speed. Some of the packages it will build are listed below.
5
5
 
6
+ **[Watch our Screencast on youtube](http://www.youtube.com/watch?feature=player_embedded&v=ki0CL3D-Llk)**
7
+
6
8
  * automake
7
9
  * bison
8
10
  * capistrano-ext
@@ -31,17 +33,12 @@ Badger Rails deploys to a Cent Os server by Capistrano for ease of use and Bash
31
33
  * Rails 3+ Project that works :)
32
34
  * gem 'mysql2' in Gemfile
33
35
  * gem 'unicorn' in Gemfile
36
+ * gem 'therubyracer' in Gemfile. This may require the gem libv8.
34
37
  * CentOS 6+ server Red Hat 6+ server or Ubuntu 10.04, 11.04, 11.10
35
38
 
36
39
  ###**Installation**
37
40
  * gem install badger-rails
38
41
 
39
- or
40
-
41
- * Pull down the repo.
42
- * In the project root directory run < gem build badger-rails.gemspec >
43
- * Then run < gem install badger-rails-(gem version).gem >
44
-
45
42
  ###**Usage**
46
43
 
47
44
  In your rails project run the command < badger generate yml > and fill out the config/badger.yml file that is generated.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('badger-rails', '1.0.2') do |p|
5
+ Echoe.new('badger-rails', '1.0.3') do |p|
6
6
  p.description = "Badger-Rails makes use of Capistrano and Badger to create a configuration for easy deployment to a remote server.\nBadger-Rails deploys to CentOs 6+ automatically building nginx, mysql, and of course ruby."
7
7
  p.summary = "Configuration for using Badger with Rails deployment."
8
8
  p.url = "http://curiousminds.github.com/badger-rails"
data/badger-rails.gemspec CHANGED
@@ -2,16 +2,16 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "badger-rails"
5
- s.version = "1.0.2"
5
+ s.version = "1.0.3"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Nathan Kelley"]
9
- s.date = "2012-12-11"
9
+ s.date = "2012-12-20"
10
10
  s.description = "Badger-Rails makes use of Capistrano and Badger to create a configuration for easy deployment to a remote server.\nBadger-Rails deploys to CentOs 6+ automatically building nginx, mysql, and of course ruby."
11
11
  s.email = "nathan@curiousminds.com"
12
12
  s.executables = ["badger"]
13
13
  s.extra_rdoc_files = ["COPYING", "README.md", "bin/badger", "lib/badger/Capfile", "lib/badger/config/deploy.rb", "lib/badger/config/rails-app.yml", "lib/badger/config/rails-app.yml.bk", "lib/badger/core/claws/app.claw", "lib/badger/core/claws/db-app.claw", "lib/badger/core/claws/rails-app.claw", "lib/badger/core/files/badger/info", "lib/badger/core/files/cap/Capfile", "lib/badger/core/files/cap/deploy.rb", "lib/badger/core/files/cap/deploy/production-app.rb", "lib/badger/core/files/cap/deploy/production.rb", "lib/badger/core/files/cap/deploy/staging-app.rb", "lib/badger/core/files/cap/deploy/staging.rb", "lib/badger/core/files/git/git", "lib/badger/core/files/god/angel/resque-dev.god", "lib/badger/core/files/god/angel/resque-stg.god", "lib/badger/core/files/god/angel/resque.god", "lib/badger/core/files/god/angel/unicorn-stg.god", "lib/badger/core/files/god/angel/unicorn.god", "lib/badger/core/files/god/god", "lib/badger/core/files/god/unicorn-stg.rb", "lib/badger/core/files/god/unicorn.rb", "lib/badger/core/files/logrotate/logrotate.conf", "lib/badger/core/files/logrotate/logrotate.cron", "lib/badger/core/files/mysql/database.yml.bk", "lib/badger/core/files/mysql/db_stats", "lib/badger/core/files/mysql/my.cnf", "lib/badger/core/files/nginx/nginx", "lib/badger/core/files/nginx/nginx.conf", "lib/badger/core/files/nginx/sites/port443.btl", "lib/badger/core/files/nginx/sites/port80.btl", "lib/badger/core/files/nginx/sites/production-web", "lib/badger/core/files/nginx/sites/staging-web", "lib/badger/core/files/postfix/main.cf", "lib/badger/core/files/postfix/master.cf", "lib/badger/core/files/redis/redis-server", "lib/badger/core/files/redis/redis.conf", "lib/badger/core/files/resque/resque.rb", "lib/badger/core/files/resque/resque.yml", "lib/badger/core/files/resque/resque_web.rb", "lib/badger/core/files/ssh/authorized_keys", "lib/badger/core/functions", "lib/badger/core/scripts/app_info", "lib/badger/core/scripts/app_scale", "lib/badger/core/scripts/remove_app", "lib/badger/core/scripts/remove_app_db", "lib/badger/core/scripts/remove_gems", "lib/badger/core/teeth/automake.th", "lib/badger/core/teeth/badger.th", "lib/badger/core/teeth/bison.th", "lib/badger/core/teeth/bundler.th", "lib/badger/core/teeth/capistrano-ext.th", "lib/badger/core/teeth/chkconfig.th", "lib/badger/core/teeth/curl.th", "lib/badger/core/teeth/faac.th", "lib/badger/core/teeth/ffmpeg.th", "lib/badger/core/teeth/firewall.th", "lib/badger/core/teeth/gcc-c++.th", "lib/badger/core/teeth/gcc.th", "lib/badger/core/teeth/git.th", "lib/badger/core/teeth/god.th", "lib/badger/core/teeth/lame.th", "lib/badger/core/teeth/libffi.th", "lib/badger/core/teeth/libid3tag.th", "lib/badger/core/teeth/libmad.th", "lib/badger/core/teeth/libogg.th", "lib/badger/core/teeth/libtool.th", "lib/badger/core/teeth/libxml2.th", "lib/badger/core/teeth/libxslt.th", "lib/badger/core/teeth/libyaml.th", "lib/badger/core/teeth/logrotate.th", "lib/badger/core/teeth/madplay.th", "lib/badger/core/teeth/make.th", "lib/badger/core/teeth/mysql-config.th", "lib/badger/core/teeth/mysql-server.th", "lib/badger/core/teeth/mysql.th", "lib/badger/core/teeth/nginx.th", "lib/badger/core/teeth/ntp.th", "lib/badger/core/teeth/openssl.th", "lib/badger/core/teeth/pcre.th", "lib/badger/core/teeth/plugins.th", "lib/badger/core/teeth/postfix.th", "lib/badger/core/teeth/pwgen.th", "lib/badger/core/teeth/rake.th", "lib/badger/core/teeth/readline.th", "lib/badger/core/teeth/redis.th", "lib/badger/core/teeth/resque.th", "lib/badger/core/teeth/ruby.th", "lib/badger/core/teeth/rubygems.th", "lib/badger/core/teeth/san_juan.th", "lib/badger/core/teeth/sox.th", "lib/badger/core/teeth/speex.th", "lib/badger/core/teeth/sqlite3.th", "lib/badger/core/teeth/ssh_keys.th", "lib/badger/core/teeth/sshpass.th", "lib/badger/core/teeth/sudo.th", "lib/badger/core/teeth/syslog-ng.th", "lib/badger/core/teeth/sysv-rc-conf.th", "lib/badger/core/teeth/x264.th", "lib/badger/core/teeth/xvid.th", "lib/badger/core/teeth/yasm.th", "lib/badger/core/teeth/zlib.th", "lib/core.rb", "lib/errors.rb"]
14
- s.files = ["BadgerGit.png", "COPYING", "LICENSING", "Manifest", "README.md", "Rakefile", "bin/badger", "lib/badger/Capfile", "lib/badger/config/deploy.rb", "lib/badger/config/rails-app.yml", "lib/badger/config/rails-app.yml.bk", "lib/badger/core/claws/app.claw", "lib/badger/core/claws/db-app.claw", "lib/badger/core/claws/rails-app.claw", "lib/badger/core/files/badger/info", "lib/badger/core/files/cap/Capfile", "lib/badger/core/files/cap/deploy.rb", "lib/badger/core/files/cap/deploy/production-app.rb", "lib/badger/core/files/cap/deploy/production.rb", "lib/badger/core/files/cap/deploy/staging-app.rb", "lib/badger/core/files/cap/deploy/staging.rb", "lib/badger/core/files/git/git", "lib/badger/core/files/god/angel/resque-dev.god", "lib/badger/core/files/god/angel/resque-stg.god", "lib/badger/core/files/god/angel/resque.god", "lib/badger/core/files/god/angel/unicorn-stg.god", "lib/badger/core/files/god/angel/unicorn.god", "lib/badger/core/files/god/god", "lib/badger/core/files/god/unicorn-stg.rb", "lib/badger/core/files/god/unicorn.rb", "lib/badger/core/files/logrotate/logrotate.conf", "lib/badger/core/files/logrotate/logrotate.cron", "lib/badger/core/files/mysql/database.yml.bk", "lib/badger/core/files/mysql/db_stats", "lib/badger/core/files/mysql/my.cnf", "lib/badger/core/files/nginx/nginx", "lib/badger/core/files/nginx/nginx.conf", "lib/badger/core/files/nginx/sites/port443.btl", "lib/badger/core/files/nginx/sites/port80.btl", "lib/badger/core/files/nginx/sites/production-web", "lib/badger/core/files/nginx/sites/staging-web", "lib/badger/core/files/postfix/main.cf", "lib/badger/core/files/postfix/master.cf", "lib/badger/core/files/redis/redis-server", "lib/badger/core/files/redis/redis.conf", "lib/badger/core/files/resque/resque.rb", "lib/badger/core/files/resque/resque.yml", "lib/badger/core/files/resque/resque_web.rb", "lib/badger/core/files/ssh/authorized_keys", "lib/badger/core/functions", "lib/badger/core/scripts/app_info", "lib/badger/core/scripts/app_scale", "lib/badger/core/scripts/remove_app", "lib/badger/core/scripts/remove_app_db", "lib/badger/core/scripts/remove_gems", "lib/badger/core/teeth/automake.th", "lib/badger/core/teeth/badger.th", "lib/badger/core/teeth/bison.th", "lib/badger/core/teeth/bundler.th", "lib/badger/core/teeth/capistrano-ext.th", "lib/badger/core/teeth/chkconfig.th", "lib/badger/core/teeth/curl.th", "lib/badger/core/teeth/faac.th", "lib/badger/core/teeth/ffmpeg.th", "lib/badger/core/teeth/firewall.th", "lib/badger/core/teeth/gcc-c++.th", "lib/badger/core/teeth/gcc.th", "lib/badger/core/teeth/git.th", "lib/badger/core/teeth/god.th", "lib/badger/core/teeth/lame.th", "lib/badger/core/teeth/libffi.th", "lib/badger/core/teeth/libid3tag.th", "lib/badger/core/teeth/libmad.th", "lib/badger/core/teeth/libogg.th", "lib/badger/core/teeth/libtool.th", "lib/badger/core/teeth/libxml2.th", "lib/badger/core/teeth/libxslt.th", "lib/badger/core/teeth/libyaml.th", "lib/badger/core/teeth/logrotate.th", "lib/badger/core/teeth/madplay.th", "lib/badger/core/teeth/make.th", "lib/badger/core/teeth/mysql-config.th", "lib/badger/core/teeth/mysql-server.th", "lib/badger/core/teeth/mysql.th", "lib/badger/core/teeth/nginx.th", "lib/badger/core/teeth/ntp.th", "lib/badger/core/teeth/openssl.th", "lib/badger/core/teeth/pcre.th", "lib/badger/core/teeth/plugins.th", "lib/badger/core/teeth/postfix.th", "lib/badger/core/teeth/pwgen.th", "lib/badger/core/teeth/rake.th", "lib/badger/core/teeth/readline.th", "lib/badger/core/teeth/redis.th", "lib/badger/core/teeth/resque.th", "lib/badger/core/teeth/ruby.th", "lib/badger/core/teeth/rubygems.th", "lib/badger/core/teeth/san_juan.th", "lib/badger/core/teeth/sox.th", "lib/badger/core/teeth/speex.th", "lib/badger/core/teeth/sqlite3.th", "lib/badger/core/teeth/ssh_keys.th", "lib/badger/core/teeth/sshpass.th", "lib/badger/core/teeth/sudo.th", "lib/badger/core/teeth/syslog-ng.th", "lib/badger/core/teeth/sysv-rc-conf.th", "lib/badger/core/teeth/x264.th", "lib/badger/core/teeth/xvid.th", "lib/badger/core/teeth/yasm.th", "lib/badger/core/teeth/zlib.th", "lib/core.rb", "lib/errors.rb", "badger-rails.gemspec"]
14
+ s.files = ["BadgerGit.png", "COPYING", "LICENSING", "Manifest", "README.md", "Rakefile", "badger-rails.gemspec", "bin/badger", "lib/badger/Capfile", "lib/badger/config/deploy.rb", "lib/badger/config/rails-app.yml", "lib/badger/config/rails-app.yml.bk", "lib/badger/core/claws/app.claw", "lib/badger/core/claws/db-app.claw", "lib/badger/core/claws/rails-app.claw", "lib/badger/core/files/badger/info", "lib/badger/core/files/cap/Capfile", "lib/badger/core/files/cap/deploy.rb", "lib/badger/core/files/cap/deploy/production-app.rb", "lib/badger/core/files/cap/deploy/production.rb", "lib/badger/core/files/cap/deploy/staging-app.rb", "lib/badger/core/files/cap/deploy/staging.rb", "lib/badger/core/files/git/git", "lib/badger/core/files/god/angel/resque-dev.god", "lib/badger/core/files/god/angel/resque-stg.god", "lib/badger/core/files/god/angel/resque.god", "lib/badger/core/files/god/angel/unicorn-stg.god", "lib/badger/core/files/god/angel/unicorn.god", "lib/badger/core/files/god/god", "lib/badger/core/files/god/unicorn-stg.rb", "lib/badger/core/files/god/unicorn.rb", "lib/badger/core/files/logrotate/logrotate.conf", "lib/badger/core/files/logrotate/logrotate.cron", "lib/badger/core/files/mysql/database.yml.bk", "lib/badger/core/files/mysql/db_stats", "lib/badger/core/files/mysql/my.cnf", "lib/badger/core/files/nginx/nginx", "lib/badger/core/files/nginx/nginx.conf", "lib/badger/core/files/nginx/sites/port443.btl", "lib/badger/core/files/nginx/sites/port80.btl", "lib/badger/core/files/nginx/sites/production-web", "lib/badger/core/files/nginx/sites/staging-web", "lib/badger/core/files/postfix/main.cf", "lib/badger/core/files/postfix/master.cf", "lib/badger/core/files/redis/redis-server", "lib/badger/core/files/redis/redis.conf", "lib/badger/core/files/resque/resque.rb", "lib/badger/core/files/resque/resque.yml", "lib/badger/core/files/resque/resque_web.rb", "lib/badger/core/files/ssh/authorized_keys", "lib/badger/core/functions", "lib/badger/core/scripts/app_info", "lib/badger/core/scripts/app_scale", "lib/badger/core/scripts/remove_app", "lib/badger/core/scripts/remove_app_db", "lib/badger/core/scripts/remove_gems", "lib/badger/core/teeth/automake.th", "lib/badger/core/teeth/badger.th", "lib/badger/core/teeth/bison.th", "lib/badger/core/teeth/bundler.th", "lib/badger/core/teeth/capistrano-ext.th", "lib/badger/core/teeth/chkconfig.th", "lib/badger/core/teeth/curl.th", "lib/badger/core/teeth/faac.th", "lib/badger/core/teeth/ffmpeg.th", "lib/badger/core/teeth/firewall.th", "lib/badger/core/teeth/gcc-c++.th", "lib/badger/core/teeth/gcc.th", "lib/badger/core/teeth/git.th", "lib/badger/core/teeth/god.th", "lib/badger/core/teeth/lame.th", "lib/badger/core/teeth/libffi.th", "lib/badger/core/teeth/libid3tag.th", "lib/badger/core/teeth/libmad.th", "lib/badger/core/teeth/libogg.th", "lib/badger/core/teeth/libtool.th", "lib/badger/core/teeth/libxml2.th", "lib/badger/core/teeth/libxslt.th", "lib/badger/core/teeth/libyaml.th", "lib/badger/core/teeth/logrotate.th", "lib/badger/core/teeth/madplay.th", "lib/badger/core/teeth/make.th", "lib/badger/core/teeth/mysql-config.th", "lib/badger/core/teeth/mysql-server.th", "lib/badger/core/teeth/mysql.th", "lib/badger/core/teeth/nginx.th", "lib/badger/core/teeth/ntp.th", "lib/badger/core/teeth/openssl.th", "lib/badger/core/teeth/pcre.th", "lib/badger/core/teeth/plugins.th", "lib/badger/core/teeth/postfix.th", "lib/badger/core/teeth/pwgen.th", "lib/badger/core/teeth/rake.th", "lib/badger/core/teeth/readline.th", "lib/badger/core/teeth/redis.th", "lib/badger/core/teeth/resque.th", "lib/badger/core/teeth/ruby.th", "lib/badger/core/teeth/rubygems.th", "lib/badger/core/teeth/san_juan.th", "lib/badger/core/teeth/sox.th", "lib/badger/core/teeth/speex.th", "lib/badger/core/teeth/sqlite3.th", "lib/badger/core/teeth/ssh_keys.th", "lib/badger/core/teeth/sshpass.th", "lib/badger/core/teeth/sudo.th", "lib/badger/core/teeth/syslog-ng.th", "lib/badger/core/teeth/sysv-rc-conf.th", "lib/badger/core/teeth/x264.th", "lib/badger/core/teeth/xvid.th", "lib/badger/core/teeth/yasm.th", "lib/badger/core/teeth/zlib.th", "lib/core.rb", "lib/errors.rb"]
15
15
  s.homepage = "http://curiousminds.github.com/badger-rails"
16
16
  s.post_install_message = "\n .-. `--\n hMMMms` `omMMMd\n NMMMMMm. `dMMMMMN`\n `-ydMMMMMd hMMMMMmy:`\n hs +NMMMM/ :MMMMMo od\n./h -NMMMh sMMMN: y/-\n dm` :MMMm hMMM/ dm`\n`/s` oMMm dMMs s/`\n :do. `mMm dMN` .+m/\n +d` yMh yMh `h+`\n .s sMo +Mh o-\n /+ dM- `Mm /+\n +/ :Mh yM+ :o\n +sNM: -MNso\n /Nd hM+\n .osmNmys-\n -:-`\n\n"
17
17
  s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Badger-rails", "--main", "README.md"]
@@ -1,10 +1,13 @@
1
1
  load "deploy"
2
- load "deploy/assets"
3
2
  require 'rubygems'
4
3
  require 'yaml'
5
4
  require 'bundler/capistrano'
6
5
  require './lib/badger_plugin.rb' if File.exists?("lib/badger_plugin.rb")
7
6
 
7
+ def test_file(full_path)
8
+ 'true' == capture("if [ -f #{full_path} ]; then echo 'true'; fi").strip
9
+ end
10
+
8
11
  `git pull origin master`
9
12
  YAML::ENGINE.yamler = 'syck'
10
13
  yml = YAML.load_file "/opt/tmp/web/config/badger.yml"
@@ -93,10 +96,22 @@ namespace :resque do
93
96
  else
94
97
  run "sudo /opt/rubygems/bin/god load /etc/badger/core/files/god/angel/resque.god"
95
98
  end
99
+ if test_file("#{release_path}/config/god/resque_scheduler.god")
100
+ run "sudo /opt/rubygems/bin/god load #{release_path}/config/god/resque_scheduler.god"
101
+ end
102
+ if test_file("#{release_path}/config/god/apn_sender.god")
103
+ run "sudo /opt/rubygems/bin/god load #{release_path}/config/god/apn_sender.god"
104
+ end
96
105
  end
97
106
 
98
107
  task :restart, :roles => :app do
99
108
  run "sudo /opt/rubygems/bin/god restart resque"
109
+ if test_file("#{release_path}/config/god/resque_scheduler.god")
110
+ run "sudo /opt/rubygems/bin/god restart scheduler"
111
+ end
112
+ if test_file("#{release_path}/config/god/apn_sender.god")
113
+ run "sudo /opt/rubygems/bin/god restart apn_sender"
114
+ end
100
115
  end
101
116
  end
102
117
 
@@ -1,10 +1,13 @@
1
1
  load "deploy"
2
- load "deploy/assets"
3
2
  require 'rubygems'
4
3
  require 'yaml'
5
4
  require 'bundler/capistrano'
6
5
  require './lib/badger_plugin.rb' if File.exists?("lib/badger_plugin.rb")
7
6
 
7
+ def test_file(full_path)
8
+ 'true' == capture("if [ -f #{full_path} ]; then echo 'true'; fi").strip
9
+ end
10
+
8
11
  `git pull origin master`
9
12
  YAML::ENGINE.yamler = 'syck'
10
13
  yml = YAML.load_file "/opt/tmp/web/config/badger.yml"
@@ -93,10 +96,22 @@ namespace :resque do
93
96
  else
94
97
  run "sudo /opt/rubygems/bin/god load /etc/badger/core/files/god/angel/resque-stg.god"
95
98
  end
99
+ if test_file("#{release_path}/config/god/resque_scheduler-stg.god")
100
+ run "sudo /opt/rubygems/bin/god load #{release_path}/config/god/resque_scheduler-stg.god"
101
+ end
102
+ if test_file("#{release_path}/config/god/apn_sender-stg.god")
103
+ run "sudo /opt/rubygems/bin/god load #{release_path}/config/god/apn_sender-stg.god"
104
+ end
96
105
  end
97
106
 
98
107
  task :restart, :roles => :app do
99
108
  run "sudo /opt/rubygems/bin/god restart resque"
109
+ if test_file("#{release_path}/config/god/resque_scheduler-stg.god")
110
+ run "sudo /opt/rubygems/bin/god restart scheduler"
111
+ end
112
+ if test_file("#{release_path}/config/god/apn_sender-stg.god")
113
+ run "sudo /opt/rubygems/bin/god restart apn_sender"
114
+ end
100
115
  end
101
116
  end
102
117
 
@@ -10,7 +10,6 @@ num_of_workers.times do |num|
10
10
  w.group = 'resque'
11
11
  w.interval = 30.seconds # default
12
12
  w.env = { 'PATH' => path, 'GEM_HOME' => '/opt/rubygems', 'RAILS_ENV' => rails_env, 'QUEUE' => 'default', 'VERBOSE' => 'true' }
13
- w.pid_file "#{SHARED_DIR}/pids/unicorn.pid"
14
13
  w.start = "/opt/rubygems/bin/rake -f #{rails_root}/Rakefile -I #{rails_root} resque:work"
15
14
  w.log = "#{shared_dir}/log/god_resque_#{num}.log"
16
15
 
@@ -1,7 +1,7 @@
1
1
  cat >> /etc/badger/core/files/nginx/sites/production-web << EOF
2
2
 
3
3
  server {
4
- listen 443;
4
+ listen ${ip}:443;
5
5
  ssl on;
6
6
  ssl_certificate /etc/ssl/${domain}.crt;
7
7
  ssl_certificate_key /etc/ssl/${domain}.key;
@@ -26,26 +26,36 @@ config_nginx() {
26
26
  }
27
27
 
28
28
  nginx_add_site() {
29
- if [ ! -z `cat /opt/tmp/web/config/badger.yml | grep certification: | grep true` ]
29
+ if [ ! -z `cat /opt/tmp/web/config/badger.yml | grep certs:` ]
30
30
  then
31
31
  if [ $1 == 'production-web' ]
32
32
  then
33
- [ "$(ls -A /opt/tmp/web/config/certs)" ] && echo "ssl" || return 0
34
- cd /opt/web/current/config/certs/
33
+ echo '============Production==========='
34
+ Ruby="yml = YAML::load_file('/opt/web/current/config/badger.yml'); puts yml['certs'].keys;" &&
35
+ keys=$(ruby -ryaml -e "$Ruby") &&
36
+ declare -a certs=($keys) &&
37
+ for c in "${certs[@]}"
38
+ do
39
+ ruby_key="yml = YAML::load_file('/opt/web/current/config/badger.yml'); puts yml['certs']['$c'];"
40
+ certification=$c
41
+ ip=$(ruby -ryaml -e "$ruby_key") || break
42
+ location=/etc/badger/core/files/nginx/sites
43
+ if [ $certification == "base" ]
44
+ then
45
+ domain=$ip
46
+ Template $location/port80.btl
47
+ else
48
+ domain=$(echo $certification | sed "s/.crt//g")
49
+ Template $location/port443.btl
35
50
 
36
- cert=$( ls | grep .crt )
37
- domain=${cert//.crt/}
38
- key=$( ls | grep .key )
39
- signing=$( ls | grep .csr )
40
-
41
- location=/etc/badger/core/files/nginx/sites
42
-
43
- Template $location/port80.btl
44
- Template $location/port443.btl
45
-
46
- Sync /opt/web/current/config/certs/$cert /etc/ssl/$cert
47
- Sync /opt/web/current/config/certs/$key /etc/ssl/$key
48
- Sync /opt/web/current/config/certs/$signing /etc/ssl/$signing
51
+ Exists /opt/web/current/config/certs/$domain.crt &&
52
+ Sync /opt/web/current/config/certs/$domain.crt /etc/ssl/$domain.crt
53
+ Exists /opt/web/current/config/certs/$domain.key &&
54
+ Sync /opt/web/current/config/certs/$domain.key /etc/ssl/$domain.key
55
+ Exists /opt/web/current/config/certs/$domain.csr &&
56
+ Sync /opt/web/current/config/certs/$domain.csr /etc/ssl/$domain.csr
57
+ fi
58
+ done
49
59
  fi
50
60
  fi
51
61
 
data/lib/core.rb CHANGED
@@ -23,7 +23,7 @@ module Methods
23
23
  end
24
24
 
25
25
  def database_server(app_claw)
26
- command = "#{app_claw}db-app.claw > #{app_claw}app.tmp; mv #{app_claw}app.tmp #{app_claw}db-app.claw"
26
+ command = "#{app_claw}db-app.claw > #{app_claw}app.tmp; mv -f #{app_claw}app.tmp #{app_claw}db-app.claw"
27
27
  case @yml['db']['redis']
28
28
  when true
29
29
  `sed 's/.*install_source_redis.*/install_source_redis/g' #{command}`
@@ -180,7 +180,7 @@ EOF
180
180
  end
181
181
 
182
182
  def rails_server(app_claw)
183
- command = "#{app_claw}rails-app.claw > #{app_claw}app.tmp; mv #{app_claw}app.tmp #{app_claw}rails-app.claw"
183
+ command = "#{app_claw}rails-app.claw > #{app_claw}app.tmp; mv -f #{app_claw}app.tmp #{app_claw}rails-app.claw"
184
184
  case @yml['redis']
185
185
  when true
186
186
  `sed 's/.*install_source_redis.*/install_source_redis/g' #{command}`
@@ -198,6 +198,14 @@ EOF
198
198
  @errors.errors('environment')
199
199
  exit
200
200
  end
201
+ if @yml['environment'] == "production"
202
+ `sed 's/.*nginx_add_site.*/nginx_add_site production-web/g' #{command}`
203
+ elsif @yml['environment'] == "staging"
204
+ `sed 's/.*nginx_add_site.*/nginx_add_site staging-web/g' #{command}`
205
+ else
206
+ @errors.errors('environment')
207
+ exit
208
+ end
201
209
  exists = `cap #{ARGV[1]} createExists`
202
210
  exists_error if exists.chomp == "true"
203
211
  `cap #{ARGV[1]} setup`
@@ -232,7 +240,7 @@ EOF
232
240
  Dir.chdir(@badger_root + "badger/")
233
241
  app_claw = @badger_root + "badger/core/claws/"
234
242
  ensure_ssh
235
- command = "#{app_claw}rails-app.claw > #{app_claw}app.tmp; mv #{app_claw}app.tmp #{app_claw}rails-app.claw"
243
+ command = "#{app_claw}rails-app.claw > #{app_claw}app.tmp; mv -f #{app_claw}app.tmp #{app_claw}rails-app.claw"
236
244
  case @yml['redis']
237
245
  when true
238
246
  `sed 's/.*install_source_redis.*/install_source_redis/g' #{command}`
@@ -250,6 +258,14 @@ EOF
250
258
  @errors.errors('environment')
251
259
  exit
252
260
  end
261
+ if @yml['environment'] == "production"
262
+ `sed 's/.*nginx_add_site.*/nginx_add_site production-web/g' #{command}`
263
+ elsif @yml['environment'] == "staging"
264
+ `sed 's/.*nginx_add_site.*/nginx_add_site staging-web/g' #{command}`
265
+ else
266
+ @errors.errors('environment')
267
+ exit
268
+ end
253
269
  exists = `cap #{ARGV[1]} exists`
254
270
  update_error if not exists.chomp == "true"
255
271
  `cap #{ARGV[1]} sync`
@@ -261,7 +277,7 @@ EOF
261
277
  end
262
278
 
263
279
  def worker_server(app_claw, app)
264
- command = "#{app_claw}app.claw > #{app_claw}app.tmp; mv #{app_claw}app.tmp #{app_claw}app.claw"
280
+ command = "#{app_claw}app.claw > #{app_claw}app.tmp; mv -f #{app_claw}app.tmp #{app_claw}app.claw"
265
281
  if @yml['environment'] == "production"
266
282
  `sed 's/.*config_capistrano.*/config_capistrano production-app #{app}/g' #{command}`
267
283
  elsif @yml['environment'] == "staging"
@@ -270,6 +286,14 @@ EOF
270
286
  @errors.errors('environment')
271
287
  exit
272
288
  end
289
+ if @yml['environment'] == "production"
290
+ `sed 's/.*nginx_add_site.*/nginx_add_site production-web/g' #{command}`
291
+ elsif @yml['environment'] == "staging"
292
+ `sed 's/.*nginx_add_site.*/nginx_add_site staging-web/g' #{command}`
293
+ else
294
+ @errors.errors('environment')
295
+ exit
296
+ end
273
297
  case @yml[app]['media']
274
298
  when true
275
299
  while true
@@ -295,8 +319,8 @@ EOF
295
319
  else
296
320
  `sed 's/.*install_media_group.*/#install_media_group/g' #{command}`
297
321
  end
298
- `echo #{@yml['password']} > #{@badger_root}badger/core/files/ssh/app;
299
- echo #{@yml['domain']} >> #{@badger_root}badger/core/files/ssh/app;
322
+ `echo '#{@yml['password']}' > #{@badger_root}badger/core/files/ssh/app;
323
+ echo '#{@yml['domain']}' >> #{@badger_root}badger/core/files/ssh/app;
300
324
  cap #{app} app_setup;
301
325
  cap #{app} app_sync;
302
326
  cap #{app} app_deploy`
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: badger-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-12-11 00:00:00.000000000 Z
12
+ date: 2012-12-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capistrano
@@ -152,6 +152,7 @@ files:
152
152
  - Manifest
153
153
  - README.md
154
154
  - Rakefile
155
+ - badger-rails.gemspec
155
156
  - bin/badger
156
157
  - lib/badger/Capfile
157
158
  - lib/badger/config/deploy.rb
@@ -258,7 +259,6 @@ files:
258
259
  - lib/badger/core/teeth/zlib.th
259
260
  - lib/core.rb
260
261
  - lib/errors.rb
261
- - badger-rails.gemspec
262
262
  homepage: http://curiousminds.github.com/badger-rails
263
263
  licenses: []
264
264
  post_install_message: ! "\n .-. `--\n hMMMms` `omMMMd\n NMMMMMm.