dpkg-tools 0.3.3 → 0.3.4
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/CHANGES +11 -0
- data/README +26 -0
- data/lib/dpkg-tools/command_line.rb +6 -3
- data/lib/dpkg-tools/package/builder.rb +13 -0
- data/lib/dpkg-tools/package/data.rb +8 -5
- data/lib/dpkg-tools/package/etc/builder.rb +16 -1
- data/lib/dpkg-tools/package/gem/setup.rb +6 -1
- data/lib/dpkg-tools/package/rails/builder.rb +2 -3
- data/lib/dpkg-tools/package/rails/data.rb +1 -1
- data/lib/dpkg-tools/package/rake.rb +18 -12
- data/lib/dpkg-tools/version.rb +2 -2
- data/resources/etc/changelog.yml +22 -0
- data/resources/etc/deb.yml +23 -0
- data/resources/etc/postinst.erb +3 -0
- data/resources/etc/prerm.erb +3 -0
- data/resources/gem/gems_to_deps.yml +45 -0
- data/resources/rails/apache.conf.erb +19 -0
- data/resources/rails/deb.yml +37 -0
- data/resources/rails/deploy.rb +51 -0
- data/resources/rails/logrotate.conf.erb +15 -0
- data/resources/rails/mongrel_cluster.yml +7 -0
- data/resources/rails/mongrel_cluster_init.erb +53 -0
- data/resources/rails/postinst.erb +63 -0
- data/resources/rails/postrm.erb +38 -0
- data/resources/rails/preinst.erb +36 -0
- data/spec/dpkg-tools/package/builder_spec.rb +136 -119
- data/spec/dpkg-tools/package/data_spec.rb +9 -0
- data/spec/dpkg-tools/package/etc/builder_spec.rb +39 -19
- data/spec/dpkg-tools/package/rails/builder_spec.rb +82 -83
- data/spec/dpkg-tools/package/rails/data_spec.rb +1 -1
- data/spec/dpkg-tools/package/rake_spec.rb +8 -2
- data/tasks/dist.rake +3 -1
- metadata +20 -3
data/CHANGES
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
== Version 0.3.4
|
2
|
+
|
3
|
+
2008-06-25: Lots of bugfixing, some small refinements.
|
4
|
+
|
5
|
+
* Added mickey-mouse usage instructions to README (http://dpkg-tools.lighthouseapp.com/projects/12374/tickets/2)
|
6
|
+
* dpkg-etc was copying its payload to the wrong place, fixing which revealed a worse underlying bad-assumption caused problem. (http://dpkg-tools.lighthouseapp.com/projects/12374/tickets/8)
|
7
|
+
* Fixed bug with dependency requirements handling which was causing dependencies without version requirements to explode when being written to the control file (http://dpkg-tools.lighthouseapp.com/projects/12374/tickets/7)
|
8
|
+
* Fixed typos in the various deb.yml templates (http://dpkg-tools.lighthouseapp.com/projects/12374/tickets/6)
|
9
|
+
* Added shebang to dpkg-etc postinst template (http://dpkg-tools.lighthouseapp.com/projects/12374/tickets/4)
|
10
|
+
* Refactored DpkgTools::Package::Builder and subclasses to fix problems with builder creation (http://dpkg-tools.lighthouseapp.com/projects/12374/tickets/1)
|
11
|
+
|
1
12
|
== Version 0.3.3
|
2
13
|
|
3
14
|
2008-06-06: Initial Rubyforge release, lots of rough edges around the process (and the software)
|
data/README
CHANGED
@@ -15,3 +15,29 @@ Or, the gem can be downloaded from http://rubyforge.org/projects/dpkg-tools/.
|
|
15
15
|
The source is available from Github: http://github.com/fidothe/dpkg-tools/, and bugs, requests and other queries can be filed at http://dpkg-tools.lighthouseapp.com/. You can clone the public Git repo with:
|
16
16
|
|
17
17
|
git clone git://github.com/fidothe/dpkg-tools.git
|
18
|
+
|
19
|
+
= How to use it
|
20
|
+
|
21
|
+
dpkg-tools comes with three utilities, to create packages from three different kinds of things. <tt>dpkg-gem</tt> makes it easy to generate .debs from local and remote rubygems. <tt>dpkg-etc</tt> makes it easy to create packages of configuration files. Finally, <tt>dpkg-rails</tt> makes it easy to package up Rails apps.
|
22
|
+
|
23
|
+
== <tt>dpkg-gem</tt>
|
24
|
+
|
25
|
+
dpkg-gem {gem_name}
|
26
|
+
|
27
|
+
This will grab the gem _gem_name_ from Rubyforge, along with all its dependencies, and create package directories for all of them. All you need to do then is run <tt>dpkg-buildpackage</tt> from inside the directory and you're away.
|
28
|
+
|
29
|
+
dpkg-gem --from-gem /path/to/rubygem.gem
|
30
|
+
|
31
|
+
Will do the same for a local .gem file.
|
32
|
+
|
33
|
+
== <tt>dpkg-etc</tt>
|
34
|
+
|
35
|
+
dpkg-etc /path/to/package/dir
|
36
|
+
|
37
|
+
Will take a directory and drop in the scaffolding needed to make it a configuration package. Configuration files go in /path/to/package/dir/etc, and dpkg-tools makes <tt>dpkg-buildpackage</tt> know what to do...
|
38
|
+
|
39
|
+
== <tt>dpkg-rails</tt>
|
40
|
+
|
41
|
+
dpkg-rails /path/to/rails/app
|
42
|
+
|
43
|
+
Will add the necessary configuration files and rake tasks to a Rails app so that a base deployment package can be generated with <tt>dpkg-buildpackage</tt>. Installing that package prepares a machine with a Mongrel cluster setup plus Apache 2's mod_proxy_balancer, allowing adding developer SSH keys for simple Capistrano deployment (tasks for that are generated too).
|
@@ -20,7 +20,8 @@ module DpkgTools
|
|
20
20
|
|
21
21
|
# Another typical switch to print the version.
|
22
22
|
opts.on_tail("--version", "Show version") do
|
23
|
-
|
23
|
+
require 'dpkg-tools/version'
|
24
|
+
err.puts DpkgTools::Version::STRING
|
24
25
|
exit
|
25
26
|
end
|
26
27
|
end
|
@@ -57,7 +58,8 @@ module DpkgTools
|
|
57
58
|
|
58
59
|
# Another typical switch to print the version.
|
59
60
|
opts.on_tail("--version", "Show version") do
|
60
|
-
|
61
|
+
require 'dpkg-tools/version'
|
62
|
+
err.puts DpkgTools::Version::STRING
|
61
63
|
exit
|
62
64
|
end
|
63
65
|
end
|
@@ -110,7 +112,8 @@ module DpkgTools
|
|
110
112
|
|
111
113
|
# Another typical switch to print the version.
|
112
114
|
opts.on_tail("--version", "Show version") do
|
113
|
-
|
115
|
+
require 'dpkg-tools/version'
|
116
|
+
err.puts DpkgTools::Version::STRING
|
114
117
|
exit
|
115
118
|
end
|
116
119
|
end
|
@@ -4,6 +4,19 @@ require 'rake'
|
|
4
4
|
module DpkgTools
|
5
5
|
module Package
|
6
6
|
class Builder
|
7
|
+
class << self
|
8
|
+
def from_path(path_to_app)
|
9
|
+
data = data_class.new(path_to_app)
|
10
|
+
self.new(data)
|
11
|
+
end
|
12
|
+
|
13
|
+
# Should be overridden by subclasses to return the specific
|
14
|
+
# DpkgTools::Package::Data subclass they want to use
|
15
|
+
def data_class
|
16
|
+
DpkgTools::Package::Data
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
7
20
|
include DpkgTools::Package::FSMethods
|
8
21
|
|
9
22
|
attr_reader :data, :config
|
@@ -40,19 +40,22 @@ module DpkgTools
|
|
40
40
|
def process_dependencies_by_type(dependencies, dependency_type, suffix = nil)
|
41
41
|
processed_dependencies = []
|
42
42
|
if dependencies.has_key?(dependency_type)
|
43
|
-
|
43
|
+
dependencies_to_process = dependencies[dependency_type]
|
44
|
+
unless dependencies_to_process.kind_of?(Array) || dependencies_to_process.nil?
|
44
45
|
raise DebYAMLParseError, "dependencies: #{dependency_type}: is not a list of items!"
|
45
46
|
end
|
46
|
-
unless
|
47
|
-
|
47
|
+
unless dependencies_to_process.nil?
|
48
|
+
dependencies_to_process.each do |dependency|
|
48
49
|
name = dependency.kind_of?(Hash) ? dependency.keys.first : dependency
|
49
50
|
requirements = dependency.kind_of?(Hash) ? dependency.values.first : nil
|
50
51
|
unless requirements.kind_of?(Array) || requirements.kind_of?(String) || requirements.nil?
|
51
52
|
raise DebYAMLParseError, "The #{dependency_type} dependency #{name}'s version requirements MUST be either a list of items, or a single item!"
|
52
53
|
end
|
53
54
|
requirements = [requirements] if requirements.kind_of?(String)
|
54
|
-
requirements.collect! { |req| yield(req) } if block_given?
|
55
|
-
|
55
|
+
requirements.collect! { |req| yield(req) } if block_given? && !requirements.nil?
|
56
|
+
processed_dependency = {:name => "#{name}#{"-"+ suffix unless suffix.nil?}"}
|
57
|
+
processed_dependency[:requirements] = requirements unless requirements.nil?
|
58
|
+
processed_dependencies << processed_dependency
|
56
59
|
end
|
57
60
|
end
|
58
61
|
end
|
@@ -2,6 +2,12 @@ module DpkgTools
|
|
2
2
|
module Package
|
3
3
|
module Etc
|
4
4
|
class Builder < DpkgTools::Package::Builder
|
5
|
+
class << self
|
6
|
+
def data_class
|
7
|
+
DpkgTools::Package::Etc::Data
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
5
11
|
def config_options
|
6
12
|
{:base_path => data.base_path}
|
7
13
|
end
|
@@ -11,7 +17,16 @@ module DpkgTools
|
|
11
17
|
end
|
12
18
|
|
13
19
|
def install_package_files
|
14
|
-
|
20
|
+
etc_path = config.base_path + '/etc'
|
21
|
+
files_to_install = Dir[etc_path + '/**/*']
|
22
|
+
files_to_install = Hash[*(files_to_install.collect {|fp| [fp, fp[(etc_path.size)..-1]]}).flatten]
|
23
|
+
files_to_install.each do |source_path, target_path|
|
24
|
+
if File.file?(source_path)
|
25
|
+
target_path = config.etc_install_path + target_path
|
26
|
+
FileUtils.mkdir_p(File.dirname(target_path))
|
27
|
+
FileUtils.install(source_path, target_path, :mode => 0644, :verbose => true)
|
28
|
+
end
|
29
|
+
end
|
15
30
|
end
|
16
31
|
end
|
17
32
|
end
|
@@ -3,8 +3,13 @@ require 'zlib'
|
|
3
3
|
require 'rubygems/package'
|
4
4
|
require 'rubygems/specification'
|
5
5
|
require 'rubygems/remote_fetcher'
|
6
|
+
begin
|
7
|
+
require 'rubygems/remote_installer'
|
8
|
+
rescue LoadError => e
|
9
|
+
puts "Ignoring LoadError due to too-new Rubygems package :-("
|
10
|
+
end
|
6
11
|
|
7
|
-
require
|
12
|
+
require 'dpkg-tools/package/gem/gem_format'
|
8
13
|
|
9
14
|
module DpkgTools
|
10
15
|
module Package
|
@@ -11,7 +11,7 @@ module DpkgTools
|
|
11
11
|
YAML.load_file(File.join(base_path, 'config', filename)) if File.exist?(File.join(base_path, 'config', filename))
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def base_package_deps
|
15
15
|
[{:name => 'mysql-client'}, {:name => 'mysql-server'}, {:name => 'apache2'},
|
16
16
|
{:name => 'ruby', :requirements => ['>= 1.8.2']}]
|
17
17
|
end
|
@@ -70,18 +70,24 @@ module DpkgTools
|
|
70
70
|
|
71
71
|
# dpkg-tools rake tasks
|
72
72
|
namespace :dpkg do
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
73
|
+
desc <<-EOD
|
74
|
+
Reset any files generated during initial setup to their pristine state.
|
75
|
+
Any of those files modified by you will be moved to <file_name>.bak first.
|
76
|
+
Identical files won't be touched.
|
77
|
+
EOD
|
78
|
+
task :reset do
|
79
|
+
setup = create_setup
|
80
|
+
setup.reset_maintainer_script_templates
|
81
|
+
setup.reset_control_files
|
82
|
+
setup.reset_package_resource_files
|
83
|
+
end
|
84
|
+
desc <<-EOD
|
85
|
+
Regenerate the control files.
|
86
|
+
Any of those files modified by you will be moved to <file_name>.bak first.
|
87
|
+
EOD
|
88
|
+
task :control do
|
89
|
+
setup = create_setup
|
90
|
+
setup.reset_control_files
|
85
91
|
end
|
86
92
|
end
|
87
93
|
end
|
data/lib/dpkg-tools/version.rb
CHANGED
@@ -3,10 +3,10 @@ module DpkgTools #:nodoc:
|
|
3
3
|
unless defined? MAJOR
|
4
4
|
MAJOR = 0
|
5
5
|
MINOR = 3
|
6
|
-
TINY =
|
6
|
+
TINY = 4
|
7
7
|
RELEASE_CANDIDATE = nil
|
8
8
|
|
9
|
-
BUILD_TIME = "2008-06-
|
9
|
+
BUILD_TIME = "2008-06-25T11:26:00+01:00"
|
10
10
|
|
11
11
|
STRING = [MAJOR, MINOR, TINY].join('.')
|
12
12
|
TAG = "REL_#{[MAJOR, MINOR, TINY, RELEASE_CANDIDATE].compact.join('_')}".upcase.gsub(/\.|-/, '_')
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# A Debian Changelog gets generated from this list of change blocks.
|
2
|
+
# date, version, and changes are required fields.
|
3
|
+
#
|
4
|
+
# Date should contain an ISO8601/RFC3339-formatted date-time string
|
5
|
+
#
|
6
|
+
# Version should be the version number of the package that this change
|
7
|
+
# applies to
|
8
|
+
#
|
9
|
+
# Changes is a list of changes. Each item should be a YAML string or block.
|
10
|
+
# (You don't need more than one item, but you do need to structure it as a
|
11
|
+
# list)
|
12
|
+
#
|
13
|
+
# You can use rake dpkg:new_change to add a new item to the top of this file
|
14
|
+
# it will fill in Date and Version for you.
|
15
|
+
- date: "2008-04-16T12:00:00+00:00"
|
16
|
+
version: "1.0.1"
|
17
|
+
changes:
|
18
|
+
- Changes!
|
19
|
+
- >
|
20
|
+
More changes!
|
21
|
+
|
22
|
+
Split across several lines!
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# The name MUST follow the conventions of Debian package naming,
|
2
|
+
# since we use the name to make a Debian package...
|
3
|
+
# Basically, lowercase letters, numbers and hyphend are fine
|
4
|
+
# everything else is verboten:
|
5
|
+
# http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Package
|
6
|
+
name: "configuration-package"
|
7
|
+
# Version is used for creating the package too. Version strings
|
8
|
+
# of the format X.Y.Z are used: 1.0, 1.0.1, etc. FYI, 1.1.5 is a
|
9
|
+
# LOWER version number than 1.10 - 1.10 is equivalent to 1.10.0
|
10
|
+
version: "1.0"
|
11
|
+
license: "(c) Matt Patterson, 2007"
|
12
|
+
summary: "Package description (mandatory)"
|
13
|
+
# To add dependencies, follow this pattern:
|
14
|
+
#
|
15
|
+
# dependencies:
|
16
|
+
# gem:
|
17
|
+
# - rspec: ">= 1.0.8"
|
18
|
+
# - redcloth:
|
19
|
+
# - ">= 1.0.0"
|
20
|
+
# - "< 2.0.0"
|
21
|
+
# package:
|
22
|
+
# - mysql-client
|
23
|
+
# - mysql-server
|
@@ -0,0 +1,45 @@
|
|
1
|
+
mysql: "libmysqlclient-dev"
|
2
|
+
# There are a couple of ways of notating deps. All the possible ways are detailed below...
|
3
|
+
#
|
4
|
+
# 1) Single dep for a specific version
|
5
|
+
# mysql:
|
6
|
+
# 2.7: "libmysqlclient-dev"
|
7
|
+
#
|
8
|
+
# mysql:
|
9
|
+
# 2.6: "libmysqlclient-dev"
|
10
|
+
# 2.7: "libmysqlclient-dev"
|
11
|
+
#
|
12
|
+
# 2) a list of deps for a specific version
|
13
|
+
# mysql:
|
14
|
+
# 2.7:
|
15
|
+
# - "libmysqlclient-dev"
|
16
|
+
# - "other-dep"
|
17
|
+
#
|
18
|
+
# mysql:
|
19
|
+
# 2.6:
|
20
|
+
# - "libmysqlclient-dev"
|
21
|
+
# 2.7:
|
22
|
+
# - "libmysqlclient-dev"
|
23
|
+
# - "other-dep"
|
24
|
+
#
|
25
|
+
# 3) lists of deps and single deps for versions
|
26
|
+
# mysql:
|
27
|
+
# 2.6: "libmysqlclient-dev"
|
28
|
+
# 2.7:
|
29
|
+
# - "libmysqlclient-dev"
|
30
|
+
# - "other-dep"
|
31
|
+
#
|
32
|
+
# 4) generic deps (with specific versions having a different list)
|
33
|
+
# mysql:
|
34
|
+
# all:
|
35
|
+
# - "libmysqlclient-dev"
|
36
|
+
# - "other-dep"
|
37
|
+
# 2.7: "libmysqlclient-dev"
|
38
|
+
#
|
39
|
+
# 5) single generic dep only
|
40
|
+
# mysql: "libmysqlclient-dev"
|
41
|
+
#
|
42
|
+
# 6) list of generic deps
|
43
|
+
# mysql:
|
44
|
+
# - "libmysqlclient-dev"
|
45
|
+
# - "other-dep"
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<Proxy balancer://mongrel_cluster>
|
2
|
+
<% mongrel_ports.each do |port| -%>
|
3
|
+
BalancerMember http://127.0.0.1:<%= port %>
|
4
|
+
<% end -%>
|
5
|
+
</Proxy>
|
6
|
+
|
7
|
+
<VirtualHost *:80>
|
8
|
+
ServerAdmin webskivvy@reprocessed.org
|
9
|
+
ServerName <%= server_name %>
|
10
|
+
<% server_aliases.each do |server_alias| -%>
|
11
|
+
ServerAlias <%= server_alias %>
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
ProxyPass / balancer://mongrel_cluster/
|
15
|
+
ProxyPassReverse / balancer://mongrel_cluster
|
16
|
+
|
17
|
+
ErrorLog /var/log/<%= name %>/apache2/error.log
|
18
|
+
CustomLog /var/log/<%= name %>/apache2/access.log combined
|
19
|
+
</VirtualHost>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# The name MUST follow the conventions of Debian package naming,
|
2
|
+
# since we use the name to make a Debian package...
|
3
|
+
# Basically, lowercase letters, numbers and hyphend are fine
|
4
|
+
# everything else is verboten.
|
5
|
+
name: "rails-app"
|
6
|
+
# Version is used for creating the package too. Version strings
|
7
|
+
# of the format X.Y.Z are used: 1.0, 1.0.1, etc. FYI, 1.1.5 is a
|
8
|
+
# LOWER version number than 1.10 - 1.10 is equivalent to 1.10.0
|
9
|
+
version: "1.0"
|
10
|
+
license: "(c) Matt Patterson, 2007"
|
11
|
+
summary: "App description (mandatory)"
|
12
|
+
server_name: "reprocessed.org"
|
13
|
+
server_aliases:
|
14
|
+
- "www.reprocessed.org"
|
15
|
+
# The values in mongrel_cluster are used to create a mongrel_cluster.yml file
|
16
|
+
# with values for log_file, cwd, and pid_file created for you
|
17
|
+
# You should edit values here and avoid editing mongrel_cluster.yml
|
18
|
+
mongrel_cluster:
|
19
|
+
port: "8000"
|
20
|
+
environment: production
|
21
|
+
address: 127.0.0.1
|
22
|
+
servers: 3
|
23
|
+
# To add dependencies, follow this pattern:
|
24
|
+
# By default, most of the things you'll need are added for you
|
25
|
+
# without you having to add them here:
|
26
|
+
# Rails, Rake, MySQL client & server, Apache 2.2, mod_proxy_balancer,
|
27
|
+
# Mongrel, mongrel_cluster
|
28
|
+
#
|
29
|
+
# dependencies:
|
30
|
+
# gem:
|
31
|
+
# - rspec: ">= 1.0.8"
|
32
|
+
# - redcloth:
|
33
|
+
# - ">= 1.0.0"
|
34
|
+
# - "< 2.0.0"
|
35
|
+
# package:
|
36
|
+
# - mysql-client
|
37
|
+
# - mysql-server
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'dpkg-tools'
|
3
|
+
|
4
|
+
set :user, DpkgTools::Package::Rails.cap.user
|
5
|
+
set :application, DpkgTools::Package::Rails.cap.application
|
6
|
+
set :repository, "set your repository location here"
|
7
|
+
|
8
|
+
set :deploy_via, :copy
|
9
|
+
set :deploy_to, DpkgTools::Package::Rails.cap.deploy_to
|
10
|
+
|
11
|
+
# If you aren't using Subversion to manage your source code, specify
|
12
|
+
# your SCM below:
|
13
|
+
# set :scm, :subversion
|
14
|
+
|
15
|
+
role :app, "your app-server here"
|
16
|
+
role :web, "your web-server here"
|
17
|
+
role :db, "your db-server here", :primary => true
|
18
|
+
|
19
|
+
namespace :deploy do
|
20
|
+
desc <<-DESC
|
21
|
+
Restarts your application. This works by calling the /etc/init.d script for the
|
22
|
+
app, with 'restart' as an option.
|
23
|
+
|
24
|
+
This will (and should) be invoked via sudo as the `app' user.
|
25
|
+
DESC
|
26
|
+
task :restart, :roles => :app, :except => { :no_release => true } do
|
27
|
+
sudo "/etc/init.d/#{application} restart"
|
28
|
+
end
|
29
|
+
|
30
|
+
desc <<-DESC
|
31
|
+
Restarts your application. This works by calling the /etc/init.d script for the
|
32
|
+
app, with 'restart' as an option.
|
33
|
+
|
34
|
+
This will (and should) be invoked via sudo as the `app' user.
|
35
|
+
DESC
|
36
|
+
task :start, :roles => :app do
|
37
|
+
sudo "/etc/init.d/#{application} start"
|
38
|
+
end
|
39
|
+
|
40
|
+
desc <<-DESC
|
41
|
+
Restarts your application. This works by calling the /etc/init.d script for the
|
42
|
+
app, with 'restart' as an option.
|
43
|
+
|
44
|
+
This will (and should) be invoked via sudo as the `app' user.
|
45
|
+
DESC
|
46
|
+
task :stop, :roles => :app do
|
47
|
+
sudo "/etc/init.d/#{application} stop"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/var/log/<%= name %>/apache2/*.log {
|
2
|
+
weekly
|
3
|
+
missingok
|
4
|
+
rotate 52
|
5
|
+
compress
|
6
|
+
delaycompress
|
7
|
+
notifempty
|
8
|
+
create 640 root adm
|
9
|
+
sharedscripts
|
10
|
+
postrotate
|
11
|
+
if [ -f /var/run/apache2.pid ]; then
|
12
|
+
/etc/init.d/apache2 restart > /dev/null
|
13
|
+
fi
|
14
|
+
endscript
|
15
|
+
}
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/bin/bash
|
2
|
+
#
|
3
|
+
# Copyright (c) 2007 Bradley Taylor, bradley@railsmachine.com
|
4
|
+
# Modified by Matt Patterson for dpkg-tools
|
5
|
+
#
|
6
|
+
# mongrel_cluster Startup script for Mongrel clusters.
|
7
|
+
#
|
8
|
+
# chkconfig: - 85 15
|
9
|
+
# description: mongrel_cluster manages multiple Mongrel processes for use \
|
10
|
+
# behind a load balancer.
|
11
|
+
#
|
12
|
+
|
13
|
+
CONF_DIR=<%= conf_dir_path %>
|
14
|
+
CONF_FILE=$CONF_DIR/mongrel_cluster.yml
|
15
|
+
PID_DIR=<%= pidfile_dir_path %>
|
16
|
+
USER=<%= username %>
|
17
|
+
|
18
|
+
RETVAL=0
|
19
|
+
|
20
|
+
# Gracefully exit if the controller is missing.
|
21
|
+
which mongrel_cluster_ctl >/dev/null || exit 0
|
22
|
+
|
23
|
+
# Go no further if config file is missing.
|
24
|
+
[ -f "$CONF_DIR/mongrel_cluster.yml" ] || exit 0
|
25
|
+
|
26
|
+
case "$1" in
|
27
|
+
start)
|
28
|
+
# Create pid directory
|
29
|
+
mkdir -p $PID_DIR
|
30
|
+
chown $USER:$USER $PID_DIR
|
31
|
+
|
32
|
+
mongrel_rails cluster::start -C $CONF_FILE
|
33
|
+
RETVAL=$?
|
34
|
+
;;
|
35
|
+
stop)
|
36
|
+
mongrel_rails cluster::stop -C $CONF_FILE
|
37
|
+
RETVAL=$?
|
38
|
+
;;
|
39
|
+
restart)
|
40
|
+
mongrel_rails cluster::restart -C $CONF_FILE
|
41
|
+
RETVAL=$?
|
42
|
+
;;
|
43
|
+
status)
|
44
|
+
mongrel_rails cluster::status -C $CONF_FILE
|
45
|
+
RETVAL=$?
|
46
|
+
;;
|
47
|
+
*)
|
48
|
+
echo "Usage: mongrel_cluster {start|stop|restart|status}"
|
49
|
+
exit 1
|
50
|
+
;;
|
51
|
+
esac
|
52
|
+
|
53
|
+
exit $RETVAL
|
@@ -0,0 +1,63 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
|
3
|
+
# Fix permission on the .ssh dir
|
4
|
+
chown -R <%= name %>:<%= name %> "<%= app_install_path %>/.ssh"
|
5
|
+
|
6
|
+
# Add the correct /etc/sudoers entries, or modify the existing one (if it's there)
|
7
|
+
# remove any existing one
|
8
|
+
SUDOERS=`sed -e '/^# #Package <%= name %> START#/, /^# #Package <%= name %> STOP#/ d' /etc/sudoers`
|
9
|
+
|
10
|
+
SUDOERS_TMP=`mktemp` || exit 1
|
11
|
+
|
12
|
+
# append the string
|
13
|
+
cat <<EOS > $SUDOERS_TMP
|
14
|
+
$SUDOERS
|
15
|
+
# #Package <%= name %> START# Autogenerated by dpkg-tools for this package, will be overwritten by package maintainer scripts
|
16
|
+
<%= user %> ALL = NOPASSWD: <%= init_script_path %> start, <%= init_script_path %> stop, <%= init_script_path %> restart
|
17
|
+
# #Package <%= name %> STOP# Autogenerated section stops
|
18
|
+
EOS
|
19
|
+
|
20
|
+
# check the syntax of the sudoers string
|
21
|
+
visudo -cf $SUDOERS_TMP
|
22
|
+
if [ $? -ne 0 ]; then
|
23
|
+
rm -f $SUDOERS_TMP
|
24
|
+
exit 1
|
25
|
+
fi
|
26
|
+
|
27
|
+
# rewrite /etc/sudoers
|
28
|
+
cat $SUDOERS_TMP > /etc/sudoers
|
29
|
+
if [ $? -ne 0 ]; then
|
30
|
+
rm -f $SUDOERS_TMP
|
31
|
+
exit 1
|
32
|
+
fi
|
33
|
+
|
34
|
+
# nuke the tmpfile
|
35
|
+
rm -f $SUDOERS_TMP
|
36
|
+
|
37
|
+
# Make the app's DB
|
38
|
+
mysql -u root <<EOT
|
39
|
+
<% if database_configurations['test'] -%>
|
40
|
+
CREATE DATABASE \`<%= database_configurations['test']['database'] %>\`;
|
41
|
+
GRANT ALL PRIVILEGES ON \`<%= database_configurations['test']['database'] %>\`.* TO \`<%= database_configurations['test']['username'] %>\`@localhost;
|
42
|
+
<% end -%>
|
43
|
+
<% if database_configurations['production'] -%>
|
44
|
+
CREATE DATABASE \`<%= database_configurations['production']['database'] %>\`;
|
45
|
+
GRANT ALL PRIVILEGES ON \`<%= database_configurations['production']['database'] %>\`.* TO \`<%= database_configurations['test']['username'] %>\`@localhost;
|
46
|
+
<% end -%>
|
47
|
+
EOT
|
48
|
+
|
49
|
+
# invoke update-rc.d to get the app's init script loaded
|
50
|
+
update-rc.d "<%= name %>" defaults 85 15
|
51
|
+
|
52
|
+
# enable apache's mod_proxy_balancer and the http proxy protocol handler
|
53
|
+
a2enmod proxy_balancer
|
54
|
+
a2enmod proxy_http
|
55
|
+
|
56
|
+
# enable the apache config we just installed
|
57
|
+
a2ensite <%= name %>
|
58
|
+
|
59
|
+
# restart apache
|
60
|
+
invoke-rc.d apache2 force-reload
|
61
|
+
|
62
|
+
# N.B. we don't spawn mongrels here - that's done through capistrano
|
63
|
+
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/bin/bash -e
|
2
|
+
|
3
|
+
# invoke update-rc.d to get the app's init script loaded
|
4
|
+
update-rc.d "<%= name %>" remove
|
5
|
+
|
6
|
+
# stop apache attempting to proxy for us
|
7
|
+
a2dissite "<%= name %>"
|
8
|
+
invoke-rc.d apache2 force-reload
|
9
|
+
|
10
|
+
# Remove the app's user if it's there
|
11
|
+
if getent passwd "<%= name %>" >/dev/null; then
|
12
|
+
# Removing system user: <%= name %>.
|
13
|
+
deluser "<%= name %>" >/dev/null
|
14
|
+
fi
|
15
|
+
|
16
|
+
# Remove the group for the app if it's there
|
17
|
+
if getent group "<%= name %>" >/dev/null; then
|
18
|
+
# Removing system group for the app: <%= name %>.
|
19
|
+
delgroup --system "<%= name %>" >/dev/null
|
20
|
+
fi
|
21
|
+
|
22
|
+
# remove the chunk of sudoers
|
23
|
+
SUDOERS_TMP=`mktemp` || exit 1
|
24
|
+
sed -e '/^# #Package <%= name %> START#/, /^# #Package <%= name %> STOP#/ d' /etc/sudoers > $SUDOERS_TMP
|
25
|
+
|
26
|
+
# check the syntax of the sudoers string
|
27
|
+
visudo -cf $SUDOERS_TMP
|
28
|
+
if [ $? -ne 0 ]; then
|
29
|
+
rm -f $SUDOERS_TMP
|
30
|
+
exit 1
|
31
|
+
fi
|
32
|
+
|
33
|
+
# rewrite /etc/sudoers
|
34
|
+
cat $SUDOERS_TMP > /etc/sudoers
|
35
|
+
if [ $? -ne 0 ]; then
|
36
|
+
rm -f $SUDOERS_TMP
|
37
|
+
exit 1
|
38
|
+
fi
|