deprec 1.7.0 → 1.7.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.
@@ -5,11 +5,15 @@
5
5
  # The '_as_root' means 'log in as root to do this'
6
6
  #
7
7
  export HOSTS=deptest.deprecated.org
8
- cap setup_admin_account_as_root
9
- cap setup_ssh_keys
8
+ cap setup_admin_account_as_root # XXX echo new username
9
+ cap setup_ssh_keys # XXX do for others also
10
10
  cap install_rails_stack
11
+ cap install_php
11
12
  cap setup
12
13
  cap deploy_with_migrations
13
14
  cap restart_apache
14
15
 
16
+ # svn+trac
17
+ cap install_svn
18
+ cap svn_setup_repos
15
19
 
@@ -75,10 +75,12 @@ module Deprec
75
75
 
76
76
  # create directory if it doesn't already exist
77
77
  # set permissions and ownership
78
- def mkdir(path, mode=0755, group=nil, user=nil)
79
- sudo "test -d #{path} || sudo mkdir -p -m#{mode} #{path}"
80
- sudo "chgrp -R #{group} #{path}" if group
81
- sudo "chown -R #{user} #{path}" if user
78
+ # XXX move mode, path and
79
+ def mkdir(path, options={})
80
+ options[:mode] ||= '0755'
81
+ sudo "test -d #{path} || sudo mkdir -p -m#{options[:mode]} #{path}"
82
+ sudo "chgrp -R #{options[:group]} #{path}" if options[:group]
83
+ sudo "chown -R #{user} #{path}" if options[:user]
82
84
  end
83
85
 
84
86
 
@@ -117,6 +119,7 @@ module Deprec
117
119
  def install_from_src(src_package, src_dir)
118
120
  package_dir = File.join(src_dir, src_package[:dir])
119
121
  unpack_src(src_package, src_dir)
122
+ apt.install( {:base => %w(build-essential)}, :stable )
120
123
  sudo <<-SUDO
121
124
  sh -c '
122
125
  cd #{package_dir};
@@ -127,6 +130,7 @@ module Deprec
127
130
  '
128
131
  SUDO
129
132
  end
133
+
130
134
 
131
135
  end
132
136
 
@@ -3,13 +3,13 @@ require 'deprec/recipes/svn'
3
3
  require 'deprec/recipes/ubuntu'
4
4
  require 'deprec/third_party/mongrel_cluster/recipes'
5
5
  require 'deprec/third_party/vmbuilder/plugins'
6
- require 'deprec/third_party/railsmachine/recipes/svn'
7
6
  require 'deprec/third_party/railsmachine/recipes/apache'
8
7
  require 'deprec/third_party/railsmachine/recipes/mysql'
9
8
  require 'deprec/capistrano_extensions/deprec_extensions.rb'
10
9
  require 'deprec/capistrano_extensions/actor_extensions.rb'
11
10
 
12
11
  Capistrano.configuration(:must_exist).load do
12
+ set :application, lambda { application = Capistrano::CLI.password_prompt "Enter application name:" }
13
13
  set :user, (defined?(user) ? user : ENV['USER']) # user who is deploying
14
14
  set :group, 'deploy' # deployment group
15
15
  set :src_dir, (defined?(src_dir) ? src_dir : '/usr/local/src') # 3rd party src on servers
@@ -184,8 +184,9 @@ Capistrano.configuration(:must_exist).load do
184
184
  :dir => version,
185
185
  :url => "http://www.apache.org/dist/httpd/#{version}.tar.gz",
186
186
  :unpack => "tar zxf #{version}.tar.gz;",
187
- :configure => %w{
187
+ :configure => %w(
188
188
  ./configure
189
+ --enable-mods-shared=all
189
190
  --enable-proxy
190
191
  --enable-proxy-balancer
191
192
  --enable-proxy-http
@@ -194,13 +195,16 @@ Capistrano.configuration(:must_exist).load do
194
195
  --enable-headers
195
196
  --enable-ssl
196
197
  --enable-deflate
197
- --with-included-apr
198
+ --with-included-apr #_so_this_recipe_doesn't_break_when_rerun
199
+ --enable-dav #_for_subversion_
200
+ --enable-so #_for_subversion_
198
201
  ;
199
- }.reject{|arg| arg.match '#'}.join(' '),
202
+ ).reject{|arg| arg.match '#'}.join(' '),
200
203
  :make => 'make;',
201
204
  :install => 'make install;',
202
205
  :post_install => 'install -b support/apachectl /etc/init.d/httpd;'
203
206
  }
207
+ apt.install( {:base => %w(zlib1g-dev zlib1g openssl libssl-dev)}, :stable )
204
208
  deprec.download_src(src_package, src_dir)
205
209
  deprec.install_from_src(src_package, src_dir)
206
210
  # ubuntu specific - should instead call generic name which can be picked up by different distros
@@ -216,7 +220,7 @@ Capistrano.configuration(:must_exist).load do
216
220
  :dir => version,
217
221
  :url => "http://www.php.net/distributions/#{version}.tar.gz",
218
222
  :unpack => "tar zxf #{version}.tar.gz;",
219
- :configure => %w{
223
+ :configure => %w(
220
224
  ./configure
221
225
  --prefix=/usr/local/php
222
226
  --with-apxs2=/usr/local/apache2/bin/apxs
@@ -238,12 +242,14 @@ Capistrano.configuration(:must_exist).load do
238
242
  --enable-mbstring
239
243
  --with-curl==/usr/lib
240
244
  ;
241
- }.reject{|arg| arg.match '#'}.join(' '),
245
+ ).reject{|arg| arg.match '#'}.join(' '),
242
246
  :make => 'make;',
243
247
  :install => 'make install;',
244
248
  :post_install => ""
245
249
  }
246
- apt.install( {:base => %w(flex libcurl3 libcurl3-dev libmcrypt-dev libmysqlclient15-dev libncurses5-dev libxml2-dev libjpeg62-dev libpng12-dev)}, :stable )
250
+ apt.install( {:base => %w(zlib1g-dev zlib1g openssl libssl-dev
251
+ flex libcurl3 libcurl3-dev libmcrypt-dev libmysqlclient15-dev libncurses5-dev
252
+ libxml2-dev libjpeg62-dev libpng12-dev)}, :stable )
247
253
  run "export CFLAGS=-O2;"
248
254
  deprec.download_src(src_package, src_dir)
249
255
  deprec.install_from_src(src_package, src_dir)
@@ -3,6 +3,19 @@ Capistrano.configuration(:must_exist).load do
3
3
  # set :user, (defined?(user) ? user : ENV['USER'])
4
4
  desc "Copies contents of ssh public keys into authorized_keys file"
5
5
  task :setup_ssh_keys do
6
+
7
+ unless ssh_options[:keys]
8
+ puts <<-ERROR
9
+
10
+ You need to define the name of your SSH key(s)
11
+ e.g. ssh_options[:keys] = %w(/Users/someuser/.ssh/id_dsa)
12
+
13
+ You can put this in your .caprc file in your home directory.
14
+
15
+ ERROR
16
+ exit
17
+ end
18
+
6
19
  sudo "test -d ~/.ssh || mkdir ~/.ssh"
7
20
  sudo "chmod 0700 ~/.ssh"
8
21
  put(ssh_options[:keys].collect{|key| File.read(key+'.pub')}.join("\n"),
@@ -1,5 +1,96 @@
1
+ require 'fileutils'
2
+
1
3
  Capistrano.configuration(:must_exist).load do
4
+
5
+ # By default, all repositories are group writable by the group 'scm'
6
+ # Originally I have envisaged this value being initialized here as:
7
+ #
8
+ # set :scm_group, lambda {'scm_' + application}
9
+ #
10
+ # however the SVN docs convinced me it's probably overkill.
11
+ # http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.serverconfig.pathbasedauthz
12
+ set :scm_group, 'scm'
13
+
14
+ set :svn_root, '/usr/local/svn'
15
+
16
+
17
+ desc "install Subversion version control system"
18
+ task :install_svn do
19
+ # svn 1.4 server improves on 1.3 and is backwards compatible with 1.3 clients
20
+ # http://subversion.tigris.org/svn_1.4_releasenotes.html
21
+ #
22
+ # We're using FSFS instead of BerkeleyDB. Read why below:
23
+ # http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.reposadmin.basics.backends
24
+ #
25
+ version = 'subversion-1.4.3'
26
+ set :src_package, {
27
+ :file => version + '.tar.gz',
28
+ :md5sum => '6b991b63e3e1f69670c9e15708e40176 subversion-1.4.3.tar.gz',
29
+ :dir => version,
30
+ :url => "http://subversion.tigris.org/downloads/#{version}.tar.gz",
31
+ :unpack => "tar zxf #{version}.tar.gz;",
32
+ :configure => %w(
33
+ ./configure
34
+ --prefix=/usr/local
35
+ --with-apxs=/usr/local/apache2/bin/apxs
36
+ --with-apr=/usr/local/apache2
37
+ --with-apr-util=/usr/local/apache2
38
+ ;
39
+ ).reject{|arg| arg.match '#'}.join(' ') , # DRY this up
40
+ :make => 'make;',
41
+ :install => 'make install;'
42
+ }
43
+ apt.install( {:base => %w(libneon25 libneon25-dev)}, :stable )
44
+ deprec.download_src(src_package, src_dir)
45
+ deprec.install_from_src(src_package, src_dir)
46
+ end
47
+
48
+ desc "create a repository and import a project"
49
+ task :svn_create_repos, :roles => :scm do
50
+ svn_repos ||= "#{svn_root}/#{application}"
51
+ deprec.groupadd(scm_group)
52
+ deprec.add_user_to_group(user, scm_group)
53
+ deprec.mkdir(svn_root, :mode => '0755')
54
+ deprec.mkdir(svn_repos, :mode => '2775', :group => scm_group)
55
+ sudo "svnadmin verify #{svn_repos} > /dev/null 2>&1 || sudo svnadmin create #{svn_repos}"
56
+ sudo "chmod -R g+w #{svn_repos}"
57
+ end
2
58
 
59
+ # XXX check through and test the next two [mike]
60
+
61
+ # from Bradley Taylors RailsMachine gem
62
+ desc "Import code into svn repository."
63
+ task :svn_import do
64
+ new_path = "../#{application}"
65
+ tags = repository.sub("trunk", "tags")
66
+ branches = repository.sub("trunk", "branches")
67
+ puts "Adding branches and tags"
68
+ system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
69
+ puts "Importing application."
70
+ system "svn import #{repository} -m 'Import'"
71
+ cwd = Dir.getwd
72
+ puts "Moving application to new directory"
73
+ Dir.chdir '../'
74
+ system "mv #{cwd} #{cwd}.imported"
75
+ puts "Checking out application."
76
+ system "svn co #{repository} #{application}"
77
+ Dir.chdir application
78
+ puts "removing log directory contents from svn"
79
+ system "svn remove log/*"
80
+ puts "ignoring log directory"
81
+ system "svn propset svn:ignore '*.log' log/"
82
+ system "svn update log/"
83
+ puts "removing tmp directory from svn"
84
+ system "svn remove tmp/"
85
+ puts "ignoring tmp directory"
86
+ system "svn propset svn:ignore '*' tmp/"
87
+ system "svn update tmp/"
88
+ puts "committing changes"
89
+ system "svn commit -m 'Removed and ignored log files and tmp'"
90
+ puts "Your repository is: #{repository}"
91
+ end
92
+
93
+ # from Bradley Taylors RailsMachine gem
3
94
  desc "remove and ignore log files and tmp from subversion"
4
95
  task :svn_remove_log_and_tmp do
5
96
  puts "removing log directory contents from svn"
@@ -15,10 +106,16 @@ Capistrano.configuration(:must_exist).load do
15
106
  puts "committing changes"
16
107
  system "svn commit -m 'Removed and ignored log files and tmp'"
17
108
  end
18
-
109
+
19
110
  desc "Cache svn name and password on the server. Useful for http-based repositories."
20
111
  task :svn_cache_credentials do
21
112
  run_with_input "svn list #{repository}"
22
113
  end
114
+
115
+ # XXX TODO
116
+ # desc "backup repository"
117
+ # task :svn_backup_respository, :roles => :scm do
118
+ # puts "read http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.reposadmin.maint.backup"
119
+ # end
23
120
 
24
121
  end
@@ -0,0 +1,17 @@
1
+ Capistrano.configuration(:must_exist).load do
2
+
3
+ task :install_trac do
4
+ version = 'trac-0.10.4'
5
+ set :src_package, {
6
+ :file => version + '.tar.gz',
7
+ :md5sum => '52a3a21ad9faafc3b59cbeb87d5a69d2 trac-0.10.4.tar.gz',
8
+ :dir => version,
9
+ :url => "http://ftp.edgewall.com/pub/trac/#{version}.tar.gz",
10
+ :unpack => "tar zxf #{version}.tar.gz;",
11
+ :install => 'python ./setup.py install --prefix=/usr/local;'
12
+ }
13
+ deprec.download_src(src_package, src_dir)
14
+ deprec.install_from_src(src_package, src_dir)
15
+ # mysql.create_database(wordpress_db_name, wordpress_db_user, wordpress_db_pass )
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ Capistrano.configuration(:must_exist).load do
2
+
3
+ set wordpress_db_name, 'wordpress'
4
+ set wordpress_db_user, 'wordpress'
5
+ set wordpress_db_pass, 'pressing'
6
+
7
+
8
+ task :install_wordpress do
9
+ version = 'wordpress-2.1.3'
10
+ set :src_package, {
11
+ :file => version + '.tar.gz',
12
+ :md5sum => 'd480bcaff18c4751eda572be878ef7bc wordpress-2.1.3.tar.gz',
13
+ :dir => 'wordpress',
14
+ :url => "http://wordpress.org/#{version}.tar.gz",
15
+ :unpack => "tar zxf #{version}.tar.gz;"
16
+ }
17
+ deprec.download_src(src_package, src_dir)
18
+ deprec.unpack_src(src_package, src_dir)
19
+ mysql.create_database(wordpress_db_name, wordpress_db_user, wordpress_db_pass )
20
+ end
21
+
22
+
23
+ end
@@ -10,6 +10,15 @@ module MySQLMethods
10
10
  end
11
11
  end
12
12
 
13
+ def create_database(db_name, user = nil, pass = nil)
14
+ sql = ["CREATE DATABASE IF NOT EXISTS #{db_name};"]
15
+ sql << "GRANT ALL PRIVILEGES ON #{user}.* TO #{user}@localhost" if user
16
+ sql << " IDENTIFIED BY '#{pass}'" if pass
17
+ sql << ';'
18
+ sql << 'flush privileges;'
19
+ mysql.execute sql, mysql_admin
20
+ end
21
+
13
22
  private
14
23
  def handle_mysql_password(user, channel, stream, data)
15
24
  logger.info data, "[database on #{channel[:host]} asked for password]"
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: deprec
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.7.0
7
- date: 2007-05-08 00:00:00 +10:00
6
+ version: 1.7.1
7
+ date: 2007-05-23 00:00:00 -07:00
8
8
  summary: deployment recipes for capistrano
9
9
  require_paths:
10
10
  - lib
@@ -51,8 +51,10 @@ files:
51
51
  - lib/deprec/recipes/ssh.rb
52
52
  - lib/deprec/recipes/svn.rb
53
53
  - lib/deprec/recipes/templates
54
+ - lib/deprec/recipes/trac.rb
54
55
  - lib/deprec/recipes/ubuntu.rb
55
56
  - lib/deprec/recipes/vmware.rb
57
+ - lib/deprec/recipes/wordpress.rb
56
58
  - lib/deprec/recipes/templates/interfaces.rhtml
57
59
  - lib/deprec/recipes/templates/postfix_main.conf
58
60
  - lib/deprec/recipes/templates/test_template.rhtml