buzzware-buzzville 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.sw?
2
+ .DS_Store
3
+ coverage
4
+ rdoc
5
+ pkg
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 buzzware
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,18 @@
1
+ = buzzville
2
+
3
+ Description goes here.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but
13
+ bump version in a commit by itself I can ignore when I pull)
14
+ * Send me a pull request. Bonus points for topic branches.
15
+
16
+ == Copyright
17
+
18
+ Copyright (c) 2009 buzzware. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,61 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "buzzville"
8
+ gem.summary = %Q{Capistrano recipes and ruby code relating to deployment}
9
+ gem.description = %Q{Capistrano recipes and ruby code relating to deployment}
10
+ gem.email = "contact@buzzware.com.au"
11
+ gem.homepage = "http://github.com/buzzware/buzzville"
12
+ gem.authors = ["buzzware"]
13
+ gem.rubyforge_project = "buzzware"
14
+ gem.add_development_dependency "thoughtbot-shoulda"
15
+ gem.add_development_dependency "buzzware-buzzcore"
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+ Jeweler::RubyforgeTasks.new do |rubyforge|
19
+ rubyforge.doc_task = "rdoc"
20
+ end
21
+ rescue LoadError
22
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
23
+ end
24
+
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new(:test) do |test|
27
+ test.libs << 'lib' << 'test'
28
+ test.pattern = 'test/**/*_test.rb'
29
+ test.verbose = true
30
+ end
31
+
32
+ begin
33
+ require 'rcov/rcovtask'
34
+ Rcov::RcovTask.new do |test|
35
+ test.libs << 'test'
36
+ test.pattern = 'test/**/*_test.rb'
37
+ test.verbose = true
38
+ end
39
+ rescue LoadError
40
+ task :rcov do
41
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
42
+ end
43
+ end
44
+
45
+ task :test => :check_dependencies
46
+
47
+ task :default => :test
48
+
49
+ require 'rake/rdoctask'
50
+ Rake::RDocTask.new do |rdoc|
51
+ if File.exist?('VERSION')
52
+ version = File.read('VERSION')
53
+ else
54
+ version = ""
55
+ end
56
+
57
+ rdoc.rdoc_dir = 'rdoc'
58
+ rdoc.title = "buzzville #{version}"
59
+ rdoc.rdoc_files.include('README*')
60
+ rdoc.rdoc_files.include('lib/**/*.rb')
61
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.1
data/buzzville.gemspec ADDED
@@ -0,0 +1,63 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{buzzville}
8
+ s.version = "0.1.1"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["buzzware"]
12
+ s.date = %q{2009-09-10}
13
+ s.description = %q{Capistrano recipes and ruby code relating to deployment}
14
+ s.email = %q{contact@buzzware.com.au}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "buzzville.gemspec",
27
+ "lib/buzzville.rb",
28
+ "lib/buzzville/recipes.rb",
29
+ "lib/buzzville/recipes/data.rb",
30
+ "lib/buzzville/recipes/files.rb",
31
+ "lib/buzzville/recipes/ssl.rb",
32
+ "lib/buzzville/recipes/user.rb",
33
+ "test/buzzville_test.rb",
34
+ "test/test_helper.rb"
35
+ ]
36
+ s.has_rdoc = true
37
+ s.homepage = %q{http://github.com/buzzware/buzzville}
38
+ s.rdoc_options = ["--charset=UTF-8"]
39
+ s.require_paths = ["lib"]
40
+ s.rubyforge_project = %q{buzzware}
41
+ s.rubygems_version = %q{1.3.1}
42
+ s.summary = %q{Capistrano recipes and ruby code relating to deployment}
43
+ s.test_files = [
44
+ "test/buzzville_test.rb",
45
+ "test/test_helper.rb"
46
+ ]
47
+
48
+ if s.respond_to? :specification_version then
49
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
50
+ s.specification_version = 2
51
+
52
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
53
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
54
+ s.add_development_dependency(%q<buzzware-buzzcore>, [">= 0"])
55
+ else
56
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
57
+ s.add_dependency(%q<buzzware-buzzcore>, [">= 0"])
58
+ end
59
+ else
60
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
61
+ s.add_dependency(%q<buzzware-buzzcore>, [">= 0"])
62
+ end
63
+ end
@@ -0,0 +1,78 @@
1
+ require 'yore/yore_core'
2
+
3
+ @@cap_config.load do
4
+ # cap stage -Dapp=spree yore:pull:p_to_d
5
+ # cap stage -Dapp=spree yore:push:d_to_p
6
+ # cap stage -Dapp=spree yore:save:p
7
+ # cap stage -Dapp=spree -Darchive=spree.tgz yore:load:p
8
+ #desc <<-DESC
9
+ # Save
10
+ #DESC
11
+
12
+ namespace :bv do
13
+ namespace :data do
14
+
15
+ def cap
16
+ @@cap_config
17
+ end
18
+
19
+ def pull_internal(aRemoteEnv,aLocalEnv)
20
+ remote_app_path = ''
21
+ local_app_path = ''
22
+ remote_file = 'blah'
23
+ local_file = 'something'
24
+ # assume yore installed remotely
25
+ cmd = "cd #{remote_app_path}; yore save"
26
+ cmd += " --kind=#{kind}" if kind
27
+ cmd += " --RAILS_ENV=#{aRemoteEnv} #{remote_file}"
28
+ run cmd
29
+ download(remote_file,local_file,:via => :scp)
30
+ local_yore = YoreCore::Yore.launch(nil,{:kind => kind,:RAILS_ENV => aLocalEnv,:basepath=>ENV['PWD']})
31
+ local_yore.load(local_file)
32
+ end
33
+
34
+ def push_internal(aLocalEnv,aRemoteEnv)
35
+ local_yore = YoreCore::Yore.launch(nil,{:kind => kind,:RAILS_ENV => aLocalEnv,:basepath=>ENV['PWD']})
36
+ remote_app_path = File.join(cap.deploy_to,'current')
37
+ local_app_path = local_yore.config[:basepath]
38
+ filename = cap.unique_app_name+"-"+Time.now.strftime('%Y%m%d-%H%M%S')
39
+ remote_file = File.join("/tmp",filename)
40
+ local_file = File.join("/tmp",filename)
41
+ local_yore.save(local_file)
42
+ upload(local_file,remote_file,:via => :scp)
43
+
44
+ run "echo $PATH"
45
+ # assume yore installed remotely
46
+ cmd = "cd #{remote_app_path}; yore load"
47
+ cmd += " --kind=#{kind}" if kind
48
+ cmd += " --RAILS_ENV=#{aRemoteEnv} #{remote_file}"
49
+ run cmd
50
+ end
51
+
52
+ namespace :pull do
53
+ task :p2d do
54
+ pull_internal('production','development')
55
+ end
56
+ task :p2p do
57
+ end
58
+ end
59
+ namespace :push do
60
+ task :d2p do
61
+ push_internal('development','production')
62
+ files.apply_permissions
63
+ deploy.restart
64
+ end
65
+ task :p2p do
66
+ end
67
+ end
68
+ #namespace :load do
69
+ # task :p do
70
+ # end
71
+ #end
72
+ #namespace :save do
73
+ # task :p do
74
+ # end
75
+ #end
76
+ end
77
+ end
78
+ end
@@ -0,0 +1,41 @@
1
+ require 'yore/yore_core'
2
+
3
+ @@cap_config.load do
4
+
5
+ namespace :bv do
6
+ namespace :files do
7
+
8
+ def cap
9
+ @@cap_config
10
+ end
11
+
12
+ def internal_permissions
13
+ case kind
14
+ when 'spree' then
15
+
16
+ #puts "set permissions for dirs and files"
17
+ #run_for_all("chmod 750",app_dir,:dirs)
18
+ #run_for_all("chmod 640",app_dir,:files)
19
+ #
20
+ #puts "set permissions for image dirs and files"
21
+ #run_for_all("chmod 770","#{public_dir}/images",:dirs)
22
+ #run_for_all("chmod 660","#{public_dir}/images",:files)
23
+
24
+ run "#{sudo} chgrp -h #{cap.apache_user} #{cap.current_path}" # this is to change owner of link, not target
25
+ run "#{sudo} chown -R #{cap.user}:#{cap.apache_user} #{cap.current_path}/" # the # is reqd to work for symlinks
26
+ run "#{sudo} chmod -R g+w #{cap.current_path}/" # unfortunately necessary as capistrano forgets to do this later with sudo
27
+ run "#{sudo} chown #{cap.apache_user}:#{cap.apache_user} #{cap.current_path}/config/environment.rb" # very important for passenger, which uses the owner of this file to run as
28
+ run "#{sudo} touch #{cap.current_path}/log/production.log"
29
+ run "#{sudo} chmod 666 #{cap.current_path}/log/production.log"
30
+ when 'rails' then
31
+ # dfdsf
32
+ end
33
+ end
34
+
35
+ task :apply_permissions do
36
+ internal_permissions
37
+ end
38
+
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,101 @@
1
+ @@cap_config.load do
2
+
3
+ namespace :bv do
4
+ namespace :ssl do
5
+ extend CapUtils
6
+
7
+ def cap
8
+ @@cap_config
9
+ end
10
+
11
+ # should set key_dir
12
+ task :new_key do
13
+ set :local_key_dir,File.expand_path('~/.ssh') unless (local_key_dir rescue false)
14
+ if !(key_name rescue false)
15
+ default_key_name = (new_user rescue nil) || 'new_key'
16
+ key_name_response = Capistrano::CLI.ui.ask("Enter a name for the key without extension (default: #{default_key_name}):").strip!
17
+ set :key_name, (key_name_response.nil? || key_name_response.empty?) ? default_key_name : key_name_response
18
+ end
19
+ pub = File.join(local_key_dir,key_name+'.pub')
20
+ ppk = File.join(local_key_dir,key_name+'.ppk')
21
+ raise StandardError.new("#{pub} or #{ppk} already exists") if File.exists?(pub) || File.exists?(ppk)
22
+ passphrase = Capistrano::CLI.password_prompt("Enter a passphrase (>= 5 characters):")
23
+ # create key - asks for name & passphrase and stores in ~/.ssh
24
+ shell "ssh-keygen -N #{passphrase} -f #{File.join(local_key_dir,key_name)}"
25
+ shell "#{sudo} mv #{File.join(local_key_dir,key_name)} #{ppk}"
26
+ shell "#{sudo} sed -i -e 's/== .*$/== #{key_name}.pub/' #{pub}"
27
+ shell "#{sudo} chown $USER #{pub}"
28
+ shell "#{sudo} chown $USER #{ppk}"
29
+ Capistrano::CLI.ui.say "created #{pub}"
30
+ Capistrano::CLI.ui.say "created #{ppk}"
31
+ Capistrano::CLI.ui.say "Recommended: ssh-add #{ppk}"
32
+ end
33
+
34
+ task :install_key do
35
+ set :new_user,Capistrano::CLI.ui.ask("Enter a username for installing the key :") unless (new_user rescue false)
36
+ set :key_name,Capistrano::CLI.ui.ask("Enter a name for the key eg. user name (without extension):") unless (key_name rescue false)
37
+ set :key_dir,"/home/#{new_user}/.ssh" unless (key_dir rescue false)
38
+ set :local_key_dir,File.expand_path("~/.ssh") unless (local_key_dir rescue false)
39
+
40
+ # prepare key dir for new_user
41
+ auth_keys = File.join(key_dir,'authorized_keys')
42
+ run "#{sudo} mkdir -p #{key_dir}"
43
+ run "#{sudo} touch #{auth_keys}"
44
+ run "#{sudo} chown #{new_user}:#{new_user} #{key_dir}"
45
+ run "#{sudo} chown #{new_user}:#{new_user} #{auth_keys}"
46
+ run "#{sudo} chmod 700 #{key_dir}"
47
+ run "#{sudo} chmod 600 #{auth_keys}"
48
+
49
+ # upload and install in authorized_keys
50
+ if capture("#{sudo} grep -q #{key_name}.pub #{auth_keys};echo $?")=='0'
51
+ puts "Key already installed. Not installing"
52
+ else
53
+ admin_dir = "/home/#{cap.user}"
54
+
55
+ run "#{sudo} rm -f #{File.join(admin_dir,key_name+'.pub')}"
56
+ upload(File.join(local_key_dir,key_name+'.pub'),File.join(admin_dir,key_name+'.pub'),:via => :scp,:mode => 600)
57
+ run "#{sudo} echo '' | #{sudo} tee -a #{auth_keys}" # new line
58
+ run "#{sudo} cat #{File.join(admin_dir,key_name+'.pub')} | #{sudo} tee -a #{auth_keys}"
59
+ run "#{sudo} rm #{File.join(admin_dir,key_name+'.pub')}"
60
+ run "#{sudo} sudo /etc/init.d/ssh restart"
61
+ end
62
+
63
+ # add to sshd_config AllowUsers if not already
64
+ allow_users = []
65
+ allow_str = capture("#{sudo} grep AllowUsers /etc/ssh/sshd_config")
66
+ allow_str.each_line do |line|
67
+ next unless line =~ /^AllowUsers /
68
+ allow_users += line.bite('AllowUsers').split(' ')
69
+ end
70
+ if !allow_users.include?(new_user)
71
+ run "#{sudo} sed -i -e 's/^AllowUsers /AllowUsers #{new_user} /' /etc/ssh/sshd_config"
72
+ end
73
+
74
+ s = <<EOS
75
+
76
+ You probably need to append :
77
+
78
+ Host #{host}
79
+ IdentityFile #{File.join(local_key_dir,key_name+'.ppk')}
80
+ User #{new_user}
81
+ Port #{sessions.values.first.transport.peer[:port]}
82
+
83
+ to your ~/.ssh/config file
84
+
85
+ and run locally :
86
+
87
+ ssh-add -K #{File.join(local_key_dir,key_name+'.ppk')}
88
+
89
+ and then you should be able to :
90
+
91
+ ssh #{new_user}@#{host}
92
+
93
+ without entering a password and the passphrase will be in your keychain.
94
+
95
+ EOS
96
+ Capistrano::CLI.ui.say(s)
97
+ end
98
+
99
+ end
100
+ end
101
+ end
@@ -0,0 +1,46 @@
1
+ @@cap_config.load do
2
+
3
+ namespace :bv do
4
+ namespace :user do
5
+ extend CapUtils
6
+
7
+ def cap
8
+ @@cap_config
9
+ end
10
+
11
+ #sudo adduser ffff
12
+ #sudo passwd ffff
13
+ #sudo usermod -a -G www-data ffff
14
+ #cd /home/ffff/
15
+ #sudo ln -s /var/www/ffff/public public
16
+ #sudo chown -h ffff:www-data public
17
+ #sudo /etc/init.d/pure-ftpd restart
18
+
19
+ task :create do
20
+ set :new_user, Capistrano::CLI.ui.ask("Enter a name for the new user:") unless (self.new_user rescue false)
21
+ password = Capistrano::CLI.password_prompt("Enter a password for the new user:") unless (self.new_password rescue false)
22
+ set :user,admin_user
23
+
24
+ adduser(new_user,password)
25
+ add_user_to_group(new_user,apache_user)
26
+
27
+ Capistrano::CLI.ui.say "please run \"sudo sudoedit /etc/sudoers\" add the following line :"
28
+ Capistrano::CLI.ui.say "#{new_user} ALL=(ALL) ALL"
29
+ end
30
+
31
+ task :new_key do
32
+ set :new_user, Capistrano::CLI.ui.ask("Enter the user name:") unless (self.new_user rescue false)
33
+ set :user,admin_user
34
+ bv.ssl.new_key
35
+ bv.ssl.install_key
36
+ end
37
+
38
+ task :delete do
39
+ set :new_user, Capistrano::CLI.ui.ask("Enter the user name:") unless (self.new_user rescue false)
40
+ set :user,admin_user
41
+ run "#{sudo} userdel -rf #{new_user}"
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,14 @@
1
+ # can :
2
+ # require 'buzzville/recipes' or
3
+ # require 'buzzville/recipes/data'
4
+
5
+ require 'capistrano'
6
+ require 'capistrano/cli'
7
+
8
+ @@cap_config = Capistrano::Configuration.respond_to?(:instance) ?
9
+ Capistrano::Configuration.instance(:must_exist) :
10
+ Capistrano.configuration(:must_exist)
11
+
12
+ #Dir.glob(File.join(File.dirname(__FILE__), '/recipes/*.rb')).each { |f| load f }
13
+ Dir.chdir(File.dirname(__FILE__)+'/..') { Dir['buzzville/recipes/*'] }.each {|f| load f }
14
+
data/lib/buzzville.rb ADDED
@@ -0,0 +1,3 @@
1
+ Dir.chdir(File.dirname(__FILE__)) { Dir['buzzcore/*'] }.each {|f| require f }
2
+
3
+
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class BuzzvilleTest < Test::Unit::TestCase
4
+ should "probably rename this file and start testing for real" do
5
+ flunk "hey buddy, you should probably rename this file and start testing for real"
6
+ end
7
+ end
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'buzzville'
8
+
9
+ class Test::Unit::TestCase
10
+ end
metadata ADDED
@@ -0,0 +1,89 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: buzzware-buzzville
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - buzzware
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-09-10 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: thoughtbot-shoulda
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ - !ruby/object:Gem::Dependency
26
+ name: buzzware-buzzcore
27
+ type: :development
28
+ version_requirement:
29
+ version_requirements: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: "0"
34
+ version:
35
+ description: Capistrano recipes and ruby code relating to deployment
36
+ email: contact@buzzware.com.au
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - LICENSE
43
+ - README.rdoc
44
+ files:
45
+ - .document
46
+ - .gitignore
47
+ - LICENSE
48
+ - README.rdoc
49
+ - Rakefile
50
+ - VERSION
51
+ - buzzville.gemspec
52
+ - lib/buzzville.rb
53
+ - lib/buzzville/recipes.rb
54
+ - lib/buzzville/recipes/data.rb
55
+ - lib/buzzville/recipes/files.rb
56
+ - lib/buzzville/recipes/ssl.rb
57
+ - lib/buzzville/recipes/user.rb
58
+ - test/buzzville_test.rb
59
+ - test/test_helper.rb
60
+ has_rdoc: true
61
+ homepage: http://github.com/buzzware/buzzville
62
+ licenses:
63
+ post_install_message:
64
+ rdoc_options:
65
+ - --charset=UTF-8
66
+ require_paths:
67
+ - lib
68
+ required_ruby_version: !ruby/object:Gem::Requirement
69
+ requirements:
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: "0"
73
+ version:
74
+ required_rubygems_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ requirements: []
81
+
82
+ rubyforge_project: buzzware
83
+ rubygems_version: 1.3.5
84
+ signing_key:
85
+ specification_version: 2
86
+ summary: Capistrano recipes and ruby code relating to deployment
87
+ test_files:
88
+ - test/buzzville_test.rb
89
+ - test/test_helper.rb