bells 0.0.3
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/History.txt +12 -0
- data/Manifest.txt +11 -0
- data/README.txt +59 -0
- data/Rakefile +19 -0
- data/bin/ring +54 -0
- data/lib/bells.rb +6 -0
- data/lib/bells/recipes.rb +0 -0
- data/lib/bells/recipes/apache.rb +68 -0
- data/lib/bells/recipes/mongrel.rb +62 -0
- data/lib/bells/recipes/tools.rb +155 -0
- data/test/test_bells.rb +2 -0
- metadata +76 -0
data/History.txt
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
== 0.0.3 / 2007-06-23
|
2
|
+
|
3
|
+
* Created bells directory within lib to put everything.
|
4
|
+
|
5
|
+
== 0.0.2 / 2007-06-23
|
6
|
+
|
7
|
+
* Changed executable name to "ring."
|
8
|
+
|
9
|
+
== 0.0.1 / 2007-06-23
|
10
|
+
|
11
|
+
* First effort at making Bells a gem. Basically just copied over the files.
|
12
|
+
|
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
bells
|
2
|
+
by Pat Nakajima
|
3
|
+
http://devthatweb.com
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
A collection of recipes for Capistrano 2.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
Currently contains recipes for:
|
12
|
+
* Apache
|
13
|
+
* SSH keys
|
14
|
+
* Aptitude package manager
|
15
|
+
* Subversion
|
16
|
+
* Ruby Gems
|
17
|
+
|
18
|
+
In development:
|
19
|
+
* (all of the above recipes)
|
20
|
+
* MySQL
|
21
|
+
* (more to come...)
|
22
|
+
|
23
|
+
== SYNOPSIS:
|
24
|
+
|
25
|
+
To view the additional tasks that bells brings, run:
|
26
|
+
$ cap bells
|
27
|
+
|
28
|
+
== REQUIREMENTS:
|
29
|
+
|
30
|
+
* Capistrano 2 Preview 2 (1.99)
|
31
|
+
|
32
|
+
== INSTALL:
|
33
|
+
|
34
|
+
sudo gem install bells
|
35
|
+
|
36
|
+
== LICENSE:
|
37
|
+
|
38
|
+
(The MIT License)
|
39
|
+
|
40
|
+
Copyright (c) 2007 Pat Nakajima
|
41
|
+
|
42
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
43
|
+
a copy of this software and associated documentation files (the
|
44
|
+
'Software'), to deal in the Software without restriction, including
|
45
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
46
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
47
|
+
permit persons to whom the Software is furnished to do so, subject to
|
48
|
+
the following conditions:
|
49
|
+
|
50
|
+
The above copyright notice and this permission notice shall be
|
51
|
+
included in all copies or substantial portions of the Software.
|
52
|
+
|
53
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
54
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
55
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
56
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
57
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
58
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
59
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/bells.rb'
|
6
|
+
|
7
|
+
Hoe.new('bells', Bells::VERSION) do |p|
|
8
|
+
p.need_zip = true
|
9
|
+
p.extra_deps = ['capistrano']
|
10
|
+
p.rubyforge_name = 'bells'
|
11
|
+
p.author = 'Pat Nakajima'
|
12
|
+
p.email = 'patnakajima@rubyforge.org'
|
13
|
+
p.summary = 'A collection of recipes for Capistrano 2'
|
14
|
+
p.description = p.paragraphs_of('README.txt', 2..5).join("\n\n")
|
15
|
+
p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
|
16
|
+
p.remote_rdoc_dir = '' # Release to root
|
17
|
+
end
|
18
|
+
|
19
|
+
# vim: syntax=Ruby
|
data/bin/ring
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'net/http'
|
5
|
+
require 'open-uri'
|
6
|
+
|
7
|
+
|
8
|
+
OptionParser.new do |opts|
|
9
|
+
opts.banner = "Usage: #{File.basename($0)} [path]"
|
10
|
+
|
11
|
+
opts.on("-h", "--help", "Displays this help info") do
|
12
|
+
puts opts
|
13
|
+
exit 0
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
opts.parse!(ARGV)
|
18
|
+
rescue OptionParser::ParseError => e
|
19
|
+
warn e.message
|
20
|
+
puts opts
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
if ARGV.empty?
|
26
|
+
abort "Please specify the directory where you want to add Bells recipes, e.g. `#{File.basename($0)} .'"
|
27
|
+
elsif !File.exists?(ARGV.first)
|
28
|
+
abort "`#{ARGV.first}' does not exist."
|
29
|
+
elsif !File.directory?(ARGV.first)
|
30
|
+
abort "`#{ARGV.first}' is not a directory."
|
31
|
+
elsif ARGV.length > 1
|
32
|
+
abort "Too many arguments; please specify only the directory to ring."
|
33
|
+
end
|
34
|
+
|
35
|
+
def unindent(string)
|
36
|
+
indentation = string[/\A\s*/]
|
37
|
+
string.strip.gsub(/^#{indentation}/, "")
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
base = ARGV.shift
|
43
|
+
file = File.join(base, 'Capfile')
|
44
|
+
if File.exists?(file)
|
45
|
+
puts "downloading Capfile additions..."
|
46
|
+
content = Net::HTTP.get URI.parse('http://svn.nakadev.com/templates/Capfile')
|
47
|
+
puts "writing `#{file}'"
|
48
|
+
File.open(file, "a") { |f| f.write(content) }
|
49
|
+
else
|
50
|
+
raise "No Capfile found!"
|
51
|
+
raise "Run 'capify .' to generate the Capfile for this project."
|
52
|
+
end
|
53
|
+
|
54
|
+
puts "done!"
|
data/lib/bells.rb
ADDED
File without changes
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'uri'
|
3
|
+
|
4
|
+
# TODO Create installation tasks
|
5
|
+
Capistrano::Configuration.instance.load do
|
6
|
+
namespace :deploy do
|
7
|
+
namespace :apache do
|
8
|
+
|
9
|
+
desc "Restarts Apache webserver"
|
10
|
+
task :restart do
|
11
|
+
sudo "#{apache_ctl} restart"
|
12
|
+
end
|
13
|
+
|
14
|
+
desc "Starts Apache webserver"
|
15
|
+
task :start do
|
16
|
+
sudo "#{apache_ctl} start"
|
17
|
+
end
|
18
|
+
|
19
|
+
desc "Stops Apache webserver"
|
20
|
+
task :stop do
|
21
|
+
sudo "#{apache_ctl} stop"
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Reload Apache webserver"
|
25
|
+
task :reload_apache do
|
26
|
+
sudo "#{apache_ctl} reload"
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Setup an apache virtual server on remote server. The directory that contains this file must be included in your httpd.conf file."
|
30
|
+
task :setup, :roles => :app do
|
31
|
+
logger.info "getting .conf template"
|
32
|
+
conf = Net::HTTP.get URI.parse('http://svn.nakadev.com/templates/virtualhost.conf')
|
33
|
+
|
34
|
+
require 'erb'
|
35
|
+
logger.info "generating #{application}.conf"
|
36
|
+
result = ERB.new(conf, nil, "<>").result(binding)
|
37
|
+
|
38
|
+
logger.info "putting #{application}.conf on #{domain}"
|
39
|
+
put result, "#{application}.conf"
|
40
|
+
sudo "mv #{application}.conf #{apache_conf}"
|
41
|
+
sudo "chown #{user}:#{group} #{apache_conf}"
|
42
|
+
sudo "chmod 775 #{apache_conf}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
namespace :local do
|
48
|
+
namespace :apache do
|
49
|
+
desc "Start apache on local machine"
|
50
|
+
task :start do
|
51
|
+
puts "Starting Apache..."
|
52
|
+
system "sudo #{local_apache_ctl_path} start"
|
53
|
+
end
|
54
|
+
|
55
|
+
desc "Stop apache on local machine"
|
56
|
+
task :stop do
|
57
|
+
puts "Stopping Apache..."
|
58
|
+
system "sudo #{local_apache_ctl_path} stop"
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Restart apache on local machine"
|
62
|
+
task :restart do
|
63
|
+
puts "Restarting Apache..."
|
64
|
+
system "sudo #{local_apache_ctl_path} restart"
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# Recipe adapted from deprec gem
|
2
|
+
namespace :deploy do
|
3
|
+
|
4
|
+
namespace :mongrel do
|
5
|
+
desc <<-DESC
|
6
|
+
Configure Mongrel processes on the app server. This uses the :use_sudo
|
7
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
8
|
+
set to true.
|
9
|
+
DESC
|
10
|
+
task :configure, :roles => :app do
|
11
|
+
set_mongrel_conf
|
12
|
+
|
13
|
+
argv = []
|
14
|
+
argv << "mongrel_rails cluster::configure"
|
15
|
+
argv << "-N #{mongrel_servers.to_s}"
|
16
|
+
argv << "-p #{mongrel_port.to_s}"
|
17
|
+
argv << "-e #{mongrel_environment}"
|
18
|
+
argv << "-a #{mongrel_address}"
|
19
|
+
argv << "-c #{current_path}"
|
20
|
+
argv << "-C #{mongrel_conf}"
|
21
|
+
cmd = argv.join " "
|
22
|
+
sudo cmd
|
23
|
+
end
|
24
|
+
|
25
|
+
desc <<-DESC
|
26
|
+
Start Mongrel processes on the app server. This uses the :use_sudo variable to determine whether to use sudo or not. By default, :use_sudo is
|
27
|
+
set to true.
|
28
|
+
DESC
|
29
|
+
task :start , :roles => :app do
|
30
|
+
set_mongrel_conf
|
31
|
+
sudo "mongrel_rails cluster::start -C #{mongrel_conf}"
|
32
|
+
end
|
33
|
+
|
34
|
+
desc <<-DESC
|
35
|
+
Restart the Mongrel processes on the app server by starting and stopping the cluster. This uses the :use_sudo
|
36
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is set to true.
|
37
|
+
DESC
|
38
|
+
task :restart , :roles => :app do
|
39
|
+
set_mongrel_conf
|
40
|
+
sudo "mongrel_rails cluster::restart -C #{mongrel_conf}"
|
41
|
+
end
|
42
|
+
|
43
|
+
desc <<-DESC
|
44
|
+
Stop the Mongrel processes on the app server. This uses the :use_sudo
|
45
|
+
variable to determine whether to use sudo or not. By default, :use_sudo is
|
46
|
+
set to true.
|
47
|
+
DESC
|
48
|
+
task :stop , :roles => :app do
|
49
|
+
set_mongrel_conf
|
50
|
+
sudo "mongrel_rails cluster::stop -C #{mongrel_conf}"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Deletes mongrel configuration file."
|
54
|
+
task :delete do
|
55
|
+
sudo "rm #{mongrel_conf}"
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_mongrel_conf
|
59
|
+
set :mongrel_conf, "/etc/mongrel_cluster/#{application}.yml" unless mongrel_conf
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
|
2
|
+
namespace :tools do
|
3
|
+
|
4
|
+
task :default do
|
5
|
+
desc = <<-DESC
|
6
|
+
|
7
|
+
Capistrano Bells
|
8
|
+
Tools Recipe
|
9
|
+
Tasks for the general maintenance and development of web applications.
|
10
|
+
|
11
|
+
DESC
|
12
|
+
puts desc
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Displays remote server uptime"
|
16
|
+
task :uptime do
|
17
|
+
run "uptime"
|
18
|
+
end
|
19
|
+
|
20
|
+
namespace :ssh do
|
21
|
+
# TODO Create SSH key generation task
|
22
|
+
desc "Copies contents of ssh public keys into authorized_keys file"
|
23
|
+
task :setup do
|
24
|
+
sudo "test -d ~/.ssh || mkdir ~/.ssh"
|
25
|
+
sudo "chmod 0700 ~/.ssh"
|
26
|
+
put(ssh_options[:keys].collect{|key| File.read(key+'.pub')}.join("\n"),
|
27
|
+
File.join('/home', user, '.ssh/authorized_keys'),
|
28
|
+
:mode => 0600 )
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
namespace :aptitude do
|
33
|
+
desc "Runs aptitude update on remote server"
|
34
|
+
task :update do
|
35
|
+
logger.info "Running aptitude update"
|
36
|
+
sudo "aptitude update"
|
37
|
+
end
|
38
|
+
|
39
|
+
desc "Runs aptitude upgrade on remote server"
|
40
|
+
task :upgrade do
|
41
|
+
sudo_with_input "aptitude upgrade", /^Do you want to continue\?/
|
42
|
+
end
|
43
|
+
|
44
|
+
desc "Search for aptitude packages on remote server"
|
45
|
+
task :search do
|
46
|
+
puts "Enter your search term:"
|
47
|
+
deb_pkg_term = $stdin.gets.chomp
|
48
|
+
logger.info "Running aptitude update"
|
49
|
+
sudo "aptitude update"
|
50
|
+
stream "aptitude search #{deb_pkg_term}"
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Installs a package using the aptitude command on the remote server."
|
54
|
+
task :install do
|
55
|
+
puts "What is the name of the package(s) you wish to install?"
|
56
|
+
deb_pkg_name = $stdin.gets.chomp
|
57
|
+
raise "Please specify deb_pkg_name" if deb_pkg_name == ''
|
58
|
+
logger.info "Updating packages..."
|
59
|
+
sudo "aptitude update"
|
60
|
+
logger.info "Installing #{deb_pkg_name}..."
|
61
|
+
sudo_with_input "aptitude install #{deb_pkg_name}", /^Do you want to continue\?/
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
namespace :svn do
|
66
|
+
desc "remove and ignore log files and tmp from subversion"
|
67
|
+
task :clean do
|
68
|
+
logger.info "removing log directory contents from svn"
|
69
|
+
system "svn remove log/*"
|
70
|
+
logger.info "ignoring log directory"
|
71
|
+
system "svn propset svn:ignore '*.log' log/"
|
72
|
+
system "svn update log/"
|
73
|
+
logger.info "ignoring tmp directory"
|
74
|
+
system "svn propset svn:ignore '*' tmp/"
|
75
|
+
system "svn update tmp/"
|
76
|
+
logger.info "committing changes"
|
77
|
+
system "svn commit -m 'Removed and ignored log files and tmp'"
|
78
|
+
end
|
79
|
+
|
80
|
+
desc "Add new files to subversion"
|
81
|
+
task :add do
|
82
|
+
logger.info "Adding unknown files to svn"
|
83
|
+
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
|
84
|
+
end
|
85
|
+
|
86
|
+
desc "Commits changes to subversion repository"
|
87
|
+
task :commit do
|
88
|
+
puts "Enter log message:"
|
89
|
+
m = $stdin.gets.chomp
|
90
|
+
logger.info "Committing changes..."
|
91
|
+
system "svn commit -m #{m}"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
namespace :gems do
|
96
|
+
task :default do
|
97
|
+
desc <<-DESC
|
98
|
+
|
99
|
+
Tasks to adminster Ruby Gems on a remote server: \
|
100
|
+
\
|
101
|
+
cap tools:gems:list \
|
102
|
+
cap tools:gems:update \
|
103
|
+
cap tools:gems:install \
|
104
|
+
cap tools:gems:remove \
|
105
|
+
|
106
|
+
DESC
|
107
|
+
puts desc
|
108
|
+
end
|
109
|
+
|
110
|
+
desc "List gems on remote server"
|
111
|
+
task :list do
|
112
|
+
stream "gem list"
|
113
|
+
end
|
114
|
+
|
115
|
+
desc "Update gems on remote server"
|
116
|
+
task :update do
|
117
|
+
sudo "gem update"
|
118
|
+
end
|
119
|
+
|
120
|
+
desc "Install a gem on the remote server"
|
121
|
+
task :install do
|
122
|
+
# TODO Figure out how to use Highline with this
|
123
|
+
puts "Enter the name of the gem you'd like to install:"
|
124
|
+
gem_name = $stdin.gets.chomp
|
125
|
+
logger.info "trying to install #{gem_name}"
|
126
|
+
sudo "gem install #{gem_name}"
|
127
|
+
end
|
128
|
+
|
129
|
+
desc "Uninstall a gem from the remote server"
|
130
|
+
task :remove do
|
131
|
+
puts "Enter the name of the gem you'd like to remove:"
|
132
|
+
gem_name = $stdin.gets.chomp
|
133
|
+
logger.info "trying to remove #{gem_name}"
|
134
|
+
sudo "gem install #{gem_name}"
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
# Tab completion task (unfinished)
|
140
|
+
# namespace :tabs do
|
141
|
+
#
|
142
|
+
# desc "Install tab completion enabler script"
|
143
|
+
# task :setup do
|
144
|
+
# system "sudo cp vendor/plugins/bells/recipes/templates/complete /usr/local/bin/"
|
145
|
+
# system "sudo chmod 755 /usr/local/bin/complete"
|
146
|
+
# File.open("~/.bashrc", File::WRONLY|File::APPEND|File::CREAT) { |f| f.puts 'complete -C /usr/local/bin/complete -o default cap' }
|
147
|
+
# end
|
148
|
+
#
|
149
|
+
# desc "Update capistrano tab completion."
|
150
|
+
# task :update do
|
151
|
+
# system "rm ~/.captabs"
|
152
|
+
# end
|
153
|
+
#
|
154
|
+
# end
|
155
|
+
end
|
data/test/test_bells.rb
ADDED
metadata
ADDED
@@ -0,0 +1,76 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.2
|
3
|
+
specification_version: 1
|
4
|
+
name: bells
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.0.3
|
7
|
+
date: 2007-06-23 00:00:00 -04:00
|
8
|
+
summary: A collection of recipes for Capistrano 2
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: patnakajima@rubyforge.org
|
12
|
+
homepage: http://www.zenspider.com/ZSS/Products/bells/
|
13
|
+
rubyforge_project: bells
|
14
|
+
description: "== FEATURES/PROBLEMS: Currently contains recipes for: * Apache * SSH keys * Aptitude package manager * Subversion * Ruby Gems In development: * (all of the above recipes) * MySQL * (more to come...) == SYNOPSIS: To view the additional tasks that bells brings, run: $ cap bells"
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Pat Nakajima
|
31
|
+
files:
|
32
|
+
- History.txt
|
33
|
+
- Manifest.txt
|
34
|
+
- README.txt
|
35
|
+
- Rakefile
|
36
|
+
- bin/ring
|
37
|
+
- lib/bells.rb
|
38
|
+
- lib/bells/recipes.rb
|
39
|
+
- lib/bells/recipes/apache.rb
|
40
|
+
- lib/bells/recipes/tools.rb
|
41
|
+
- lib/bells/recipes/mongrel.rb
|
42
|
+
- test/test_bells.rb
|
43
|
+
test_files:
|
44
|
+
- test/test_bells.rb
|
45
|
+
rdoc_options:
|
46
|
+
- --main
|
47
|
+
- README.txt
|
48
|
+
extra_rdoc_files:
|
49
|
+
- History.txt
|
50
|
+
- Manifest.txt
|
51
|
+
- README.txt
|
52
|
+
executables:
|
53
|
+
- ring
|
54
|
+
extensions: []
|
55
|
+
|
56
|
+
requirements: []
|
57
|
+
|
58
|
+
dependencies:
|
59
|
+
- !ruby/object:Gem::Dependency
|
60
|
+
name: capistrano
|
61
|
+
version_requirement:
|
62
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
63
|
+
requirements:
|
64
|
+
- - ">"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 0.0.0
|
67
|
+
version:
|
68
|
+
- !ruby/object:Gem::Dependency
|
69
|
+
name: hoe
|
70
|
+
version_requirement:
|
71
|
+
version_requirements: !ruby/object:Gem::Version::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.2.1
|
76
|
+
version:
|