deprec 1.9.3 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +280 -0
- data/COPYING +19 -0
- data/LICENSE +339 -0
- data/README +152 -0
- data/THANKS +17 -0
- data/bin/depify +128 -0
- data/docs/EXAMPLE-installing_tracks.txt +41 -0
- data/docs/README.nagios +22 -0
- data/docs/README.rails +17 -0
- data/docs/config_gen_explained.txt +39 -0
- data/docs/{README.quickstart → deprec-1.x/deprec-1.x.quickstart} +4 -1
- data/docs/{building_edge_capistrano.txt → deprec-1.x/notes.txt} +6 -3
- data/docs/old/deprec_banner.gif +0 -0
- data/docs/windows_linux.txt +350 -0
- data/docs/xen/traffic_monitoring_with_vnstat.txt +95 -0
- data/docs/xen/xen-tools-notes.txt +31 -0
- data/docs/xen/xen_on_hardy.txt +39 -0
- data/lib/deprec.rb +8 -1
- data/lib/deprec/capistrano_extensions.rb +442 -0
- data/lib/deprec/recipes.rb +50 -233
- data/lib/deprec/recipes/aoe.rb +79 -0
- data/lib/deprec/recipes/app/mongrel.rb +213 -0
- data/lib/deprec/recipes/app/passenger.rb +197 -0
- data/lib/deprec/recipes/apt_mirror.rb +99 -0
- data/lib/deprec/recipes/ar_sendmail.rb +67 -0
- data/lib/deprec/recipes/canonical.rb +68 -0
- data/lib/deprec/recipes/db/mysql.rb +144 -0
- data/lib/deprec/recipes/db/postgresql.rb +104 -0
- data/lib/deprec/recipes/db/sqlite.rb +37 -0
- data/lib/deprec/recipes/ddclient.rb +51 -0
- data/lib/deprec/recipes/deprec.rb +199 -0
- data/lib/deprec/recipes/deprecated.rb +71 -0
- data/lib/deprec/recipes/example.rb +115 -0
- data/lib/deprec/recipes/git.rb +97 -0
- data/lib/deprec/recipes/gitosis.rb +48 -0
- data/lib/deprec/recipes/heartbeat.rb +138 -0
- data/lib/deprec/recipes/logrotate.rb +54 -0
- data/lib/deprec/recipes/lvm.rb +20 -0
- data/lib/deprec/recipes/memcache.rb +6 -2
- data/lib/deprec/recipes/monit.rb +143 -0
- data/lib/deprec/recipes/nagios.rb +305 -0
- data/lib/deprec/recipes/network.rb +93 -0
- data/lib/deprec/recipes/ntp.rb +103 -0
- data/lib/deprec/recipes/php.rb +58 -0
- data/lib/deprec/recipes/postfix.rb +115 -0
- data/lib/deprec/recipes/rails.rb +300 -55
- data/lib/deprec/recipes/ruby/mri.rb +55 -0
- data/lib/deprec/recipes/ruby/ree.rb +41 -0
- data/lib/deprec/recipes/sphinx.rb +86 -0
- data/lib/deprec/recipes/ssh.rb +85 -18
- data/lib/deprec/recipes/ssl.rb +55 -0
- data/lib/deprec/recipes/starling.rb +119 -0
- data/lib/deprec/recipes/svn.rb +163 -183
- data/lib/deprec/recipes/trac.rb +239 -62
- data/lib/deprec/recipes/ubuntu.rb +18 -100
- data/lib/deprec/recipes/users.rb +90 -0
- data/lib/deprec/recipes/utils.rb +58 -0
- data/lib/deprec/recipes/vnstat.rb +85 -0
- data/lib/deprec/recipes/web/apache.rb +119 -0
- data/lib/deprec/recipes/web/nginx.rb +172 -0
- data/lib/deprec/recipes/wordpress.rb +96 -0
- data/lib/deprec/recipes/wpmu.rb +103 -0
- data/lib/deprec/recipes/xen.rb +267 -0
- data/lib/deprec/recipes/xentools.rb +75 -0
- data/lib/deprec/templates/aoe/aoe-init +55 -0
- data/lib/deprec/templates/aoe/fence_aoemask +351 -0
- data/lib/deprec/templates/apache/namevirtualhosts.conf +5 -0
- data/lib/deprec/templates/apt/sources.list +18 -0
- data/lib/deprec/templates/apt_mirror/apt-mirror-cron +4 -0
- data/lib/deprec/templates/apt_mirror/mirror.list +33 -0
- data/lib/deprec/templates/ar_sendmail/logrotate.conf.erb +9 -0
- data/lib/deprec/templates/ar_sendmail/monit.conf.erb +5 -0
- data/lib/deprec/templates/ddclient/ddclient.conf.erb +11 -0
- data/lib/deprec/templates/ddclient/ddclient.erb +15 -0
- data/lib/deprec/templates/deprec/caprc.erb +14 -0
- data/lib/deprec/templates/heartbeat/authkeys.erb +2 -0
- data/lib/deprec/templates/heartbeat/ha.cf.erb +15 -0
- data/lib/deprec/templates/heartbeat/haresources.erb +1 -0
- data/lib/deprec/templates/logrotate/logrotate.conf.erb +32 -0
- data/lib/deprec/templates/mongrel/apache_vhost.erb +148 -0
- data/lib/deprec/templates/mongrel/logrotate.conf.erb +11 -0
- data/lib/deprec/{third_party/mongrel_cluster/resources/mongrel_cluster → templates/mongrel/mongrel_cluster-init-script} +19 -6
- data/lib/deprec/templates/mongrel/mongrel_cluster.yml.erb +10 -0
- data/lib/deprec/templates/mongrel/monit.conf.erb +17 -0
- data/lib/deprec/templates/mongrel/nginx_vhost.erb +41 -0
- data/lib/deprec/templates/monit/monit-init-script +104 -0
- data/lib/deprec/templates/monit/monitrc.erb +227 -0
- data/lib/deprec/templates/monit/nothing +0 -0
- data/lib/deprec/templates/mysql/create_databases.sql +20 -0
- data/lib/deprec/templates/mysql/database.yml.prod +6 -0
- data/lib/deprec/templates/mysql/database.yml.stage +6 -0
- data/lib/deprec/templates/mysql/my.cnf.erb +140 -0
- data/lib/deprec/templates/mysql/sphinx.conf.prod +542 -0
- data/lib/deprec/templates/mysql/sphinx.conf.stage +542 -0
- data/lib/deprec/templates/nagios/cgi.cfg.erb +321 -0
- data/lib/deprec/templates/nagios/check_linux_free_memory.pl +118 -0
- data/lib/deprec/templates/nagios/check_mongrel_cluster.rb +82 -0
- data/lib/deprec/templates/nagios/commands.cfg.erb +240 -0
- data/lib/deprec/templates/nagios/contacts.cfg.erb +57 -0
- data/lib/deprec/templates/nagios/hosts.cfg.erb +143 -0
- data/lib/deprec/templates/nagios/htpasswd.users +1 -0
- data/lib/deprec/templates/nagios/localhost.cfg.erb +157 -0
- data/lib/deprec/templates/nagios/nagios.cfg.erb +1274 -0
- data/lib/deprec/templates/nagios/nagios_apache_vhost.conf.erb +45 -0
- data/lib/deprec/templates/nagios/nrpe.cfg.erb +210 -0
- data/lib/deprec/templates/nagios/nrpe.xinetd.erb +16 -0
- data/lib/deprec/templates/nagios/resource.cfg.erb +34 -0
- data/lib/deprec/templates/nagios/services.cfg.erb +79 -0
- data/lib/deprec/templates/nagios/templates.cfg.erb +9 -0
- data/lib/deprec/templates/nagios/timeperiods.cfg.erb +94 -0
- data/lib/deprec/templates/network/hostname.erb +1 -0
- data/lib/deprec/templates/network/hosts.erb +2 -0
- data/lib/deprec/templates/network/interfaces.erb +18 -0
- data/lib/deprec/templates/network/resolv.conf.erb +6 -0
- data/lib/deprec/templates/nginx/logrotate.conf.erb +13 -0
- data/lib/deprec/templates/nginx/mime.types.erb +70 -0
- data/lib/deprec/templates/nginx/nginx-init-script +62 -0
- data/lib/deprec/templates/nginx/nginx.conf.erb +125 -0
- data/lib/deprec/templates/nginx/nginx.logrotate.d +12 -0
- data/lib/deprec/templates/nginx/nothing.conf +1 -0
- data/lib/deprec/templates/nginx/rails_nginx_vhost.conf.erb +41 -0
- data/lib/deprec/templates/ntp/ntp.conf.erb +42 -0
- data/lib/deprec/templates/passenger/apache_vhost.erb +21 -0
- data/lib/deprec/templates/passenger/passenger.conf.erb +21 -0
- data/lib/deprec/templates/passenger/passenger.load.erb +3 -0
- data/lib/deprec/templates/postfix/aliases.erb +3 -0
- data/lib/deprec/templates/postfix/dynamicmaps.cf.erb +8 -0
- data/lib/deprec/templates/{postfix_main.conf → postfix/main.cf.erb} +6 -8
- data/lib/deprec/templates/postfix/master.cf.erb +77 -0
- data/lib/deprec/templates/sphinx/monit.conf.erb +5 -0
- data/lib/deprec/templates/ssh/ssh_config.erb +50 -0
- data/lib/deprec/templates/ssh/sshd_config.erb +78 -0
- data/lib/deprec/templates/ssl/make-ssl-cert +138 -0
- data/lib/deprec/templates/ssl/ssl-cert-snakeoil.key +15 -0
- data/lib/deprec/templates/ssl/ssl-cert-snakeoil.pem +19 -0
- data/lib/deprec/templates/starling/monit.conf.erb +14 -0
- data/lib/deprec/templates/starling/starling-init-script.erb +71 -0
- data/lib/deprec/templates/subversion/svn.apache.vhost.erb +43 -0
- data/lib/deprec/templates/trac/apache_vhost.conf.erb +24 -0
- data/lib/deprec/templates/trac/nginx_vhost.conf.erb +26 -0
- data/lib/deprec/templates/trac/trac.ini.erb +169 -0
- data/lib/deprec/templates/trac/trac_deprec.png +0 -0
- data/lib/deprec/templates/trac/tracd-init.erb +43 -0
- data/lib/deprec/templates/trac/users.htdigest.erb +0 -0
- data/lib/deprec/templates/vnstat/config.php +57 -0
- data/lib/deprec/templates/wordpress/apache2_wordpress_vhost.conf.erb +31 -0
- data/lib/deprec/templates/wordpress/wp-config.php.erb +31 -0
- data/lib/deprec/templates/wpmu/apache_vhost.conf.erb +13 -0
- data/lib/deprec/templates/xen/network-bridge-wrapper +3 -0
- data/lib/deprec/templates/xen/xend-config.sxp.erb +195 -0
- data/lib/deprec/templates/xen/xend-init.erb +57 -0
- data/lib/deprec/templates/xen/xendomains.erb +137 -0
- data/lib/deprec/templates/xentools/15-disable-hwclock +40 -0
- data/lib/deprec/templates/xentools/40-setup-networking +145 -0
- data/lib/deprec/templates/xentools/xen-tools.conf.erb +276 -0
- data/lib/deprec/templates/xentools/xm.tmpl.erb +138 -0
- data/lib/deprec_cmd_completion.sh +26 -0
- data/lib/vmbuilder_plugins/all.rb +20 -0
- data/lib/vmbuilder_plugins/apt.rb +93 -0
- data/lib/vmbuilder_plugins/emerge.rb +76 -0
- data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/gem.rb +10 -17
- data/lib/{deprec/third_party/vmbuilder/plugins → vmbuilder_plugins}/std.rb +69 -19
- metadata +204 -55
- data/bin/deprec +0 -35
- data/docs/README.slicehost +0 -14
- data/docs/README.svn_trac +0 -19
- data/lib/deprec/capistrano_extensions/actor_extensions.rb +0 -89
- data/lib/deprec/capistrano_extensions/cli_extensions.rb +0 -38
- data/lib/deprec/capistrano_extensions/deprec_extensions.rb +0 -137
- data/lib/deprec/generators/deprec/USAGE +0 -11
- data/lib/deprec/generators/deprec/deprec_generator.rb +0 -24
- data/lib/deprec/generators/deprec/templates/deploy.rb +0 -90
- data/lib/deprec/generators/loader.rb +0 -20
- data/lib/deprec/recipes/apache.rb +0 -91
- data/lib/deprec/recipes/cache_svn.rb +0 -74
- data/lib/deprec/recipes/vmware.rb +0 -114
- data/lib/deprec/templates/trac.ini.erb +0 -106
- data/lib/deprec/third_party/THIRD_PARTY_README +0 -12
- data/lib/deprec/third_party/mongrel_cluster/LICENSE +0 -506
- data/lib/deprec/third_party/mongrel_cluster/recipes.rb +0 -96
- data/lib/deprec/third_party/railsmachine/LICENSE +0 -506
- data/lib/deprec/third_party/railsmachine/recipes/apache.rb +0 -92
- data/lib/deprec/third_party/railsmachine/recipes/mysql.rb +0 -73
- data/lib/deprec/third_party/railsmachine/recipes/templates/httpd-ssl.conf +0 -80
- data/lib/deprec/third_party/railsmachine/recipes/templates/httpd.conf +0 -57
- data/lib/deprec/third_party/vmbuilder/plugins.rb +0 -8
- data/lib/deprec/third_party/vmbuilder/plugins/apt.rb +0 -144
- data/resources/capistrano_include_dotfiles.patch +0 -17
data/lib/deprec/recipes/svn.rb
CHANGED
@@ -1,191 +1,171 @@
|
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
1
2
|
require 'fileutils'
|
2
3
|
require 'uri'
|
3
4
|
|
4
|
-
|
5
|
-
|
6
|
-
# By default, all repositories are group writable by the group 'scm'
|
7
|
-
# Originally I have envisaged this value being initialized here as:
|
8
|
-
#
|
9
|
-
# set :scm_group, lambda {'scm_' + application}
|
10
|
-
#
|
11
|
-
# however the SVN docs convinced me it's probably overkill.
|
12
|
-
# http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.serverconfig.pathbasedauthz
|
13
|
-
#
|
14
|
-
set :scm_group, 'scm'
|
15
|
-
|
16
|
-
# The following values define the svn repository to work with.
|
17
|
-
# If any are undefined but :repository is set, we'll extract the
|
18
|
-
# necessary values from it, otherwise we'll prompt the user.
|
19
|
-
#
|
20
|
-
# An example of :repository entries are:
|
21
|
-
#
|
22
|
-
# set :repository, 'svn+ssh://scm.deprecated.org/var/svn/deprec/trunk'
|
23
|
-
# set :repository, 'file:///tmp/svn/deprec/trunk'
|
24
|
-
#
|
25
|
-
# I've only used svn+ssh but it shouldn't be hard to get the file scheme working.
|
26
|
-
#
|
27
|
-
set (:svn_scheme) do
|
28
|
-
repository ? URI.parse(repository).scheme : 'svn+ssh'
|
29
|
-
end
|
30
|
-
|
31
|
-
set (:scm_host) do
|
32
|
-
if repository
|
33
|
-
URI.parse(repository).host || 'localhost'
|
34
|
-
elsif ENV['HOSTS']
|
35
|
-
svn_host = ENV['HOSTS']
|
36
|
-
else
|
37
|
-
Capistrano::CLI.prompt('svn host')
|
38
|
-
end
|
39
|
-
end
|
5
|
+
# http://svnbook.red-bean.com/en/1.4/svn-book.html#svn.serverconfig.choosing.apache
|
40
6
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
7
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
8
|
+
namespace :deprec do
|
9
|
+
namespace :svn do
|
10
|
+
|
11
|
+
set :scm_group, 'scm'
|
12
|
+
|
13
|
+
# Extract svn attributes from :repository URL
|
14
|
+
#
|
15
|
+
# Two examples of :repository entries are:
|
16
|
+
#
|
17
|
+
# set :repository, 'svn+ssh://scm.deprecated.org/var/svn/deprec/trunk'
|
18
|
+
# set :repository, 'file:///tmp/svn/deprec/trunk'
|
19
|
+
#
|
20
|
+
# This has only been tested with svn+ssh but file: should work.
|
21
|
+
#
|
22
|
+
set (:svn_scheme) { URI.parse(repository).scheme }
|
23
|
+
set (:svn_host) { URI.parse(repository).host }
|
24
|
+
set (:repos_path) { URI.parse(repository).path }
|
25
|
+
set (:repos_root) {
|
26
|
+
URI.parse(repository).path.sub(/\/(trunk|tags|branches)$/, '')
|
27
|
+
}
|
28
|
+
|
29
|
+
# account name to perform actions on (such as granting access to an account)
|
30
|
+
# this is a hack to allow us to optionally pass a variable to tasks
|
31
|
+
set (:svn_account) do
|
32
|
+
Capistrano::CLI.ui.ask 'account name'
|
33
|
+
end
|
34
|
+
|
35
|
+
set(:svn_backup_dir) { File.join(backup_dir, 'svn') }
|
36
|
+
|
37
|
+
desc "Install Subversion"
|
38
|
+
task :install do
|
39
|
+
install_deps
|
40
|
+
# XXX should really check if apache has already been installed
|
41
|
+
# XXX can do that when we move to rake
|
42
|
+
# deprec2.download_src(src_package, src_dir)
|
43
|
+
# deprec2.install_from_src(src_package, src_dir)
|
44
|
+
end
|
45
|
+
|
46
|
+
desc "install dependencies for Subversion"
|
47
|
+
task :install_deps do
|
48
|
+
apt.install( {:base => %w(subversion)}, :stable )
|
49
|
+
# XXX deprec1 - was building from source to get subversion-1.4.5 onto dapper. Compiled swig bindings for trac
|
50
|
+
# apt.install( {:base => %w(build-essential wget libneon25 libneon25-dev swig python-dev libexpat1-dev)}, :stable )
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "grant a user access to svn repos"
|
54
|
+
task :grant_user_access, :roles => :scm do
|
55
|
+
# creates account, scm_group and adds account to group
|
56
|
+
deprec2.useradd(svn_account)
|
57
|
+
deprec2.groupadd(scm_group)
|
58
|
+
deprec2.add_user_to_group(svn_account, scm_group)
|
59
|
+
end
|
60
|
+
|
61
|
+
desc "Create subversion repository and import project into it"
|
62
|
+
task :setup, :roles => :scm do
|
63
|
+
create_repos
|
64
|
+
import
|
65
|
+
end
|
66
|
+
|
67
|
+
desc "Create a subversion repository"
|
68
|
+
task :create_repos, :roles => :scm do
|
69
|
+
set :svn_account, top.user
|
70
|
+
grant_user_access
|
71
|
+
deprec2.mkdir(repos_root, :mode => 02775, :group => scm_group, :via => :sudo)
|
72
|
+
sudo "svnadmin verify #{repos_root} > /dev/null 2>&1 || sudo svnadmin create #{repos_root}"
|
73
|
+
sudo "chmod -R g+w #{repos_root}"
|
74
|
+
end
|
75
|
+
|
76
|
+
# Adapted from code in Bradley Taylors RailsMachine gem
|
77
|
+
desc "Import project into subversion repository."
|
78
|
+
task :import, :roles => :scm do
|
79
|
+
new_path = "../#{application}"
|
80
|
+
tags = repository.sub("trunk", "tags")
|
81
|
+
branches = repository.sub("trunk", "branches")
|
82
|
+
puts "Adding branches and tags"
|
83
|
+
system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
|
84
|
+
puts "Importing application."
|
85
|
+
system "svn import #{repository} -m 'Import'"
|
86
|
+
cwd = Dir.getwd
|
87
|
+
puts "Moving application to new directory"
|
88
|
+
Dir.chdir '../'
|
89
|
+
system "mv #{cwd} #{cwd}.imported"
|
90
|
+
puts "Checking out application."
|
91
|
+
system "svn co #{repository} #{application}"
|
92
|
+
Dir.chdir application
|
93
|
+
remove_log_and_tmp
|
94
|
+
puts "Your repository is: #{repository}"
|
95
|
+
end
|
96
|
+
|
97
|
+
# Lifted from Bradley Taylors RailsMachine gem
|
98
|
+
desc "remove and ignore log files and tmp from subversion"
|
99
|
+
task :remove_log_and_tmp, :roles => :scm do
|
100
|
+
puts "removing log directory contents from svn"
|
101
|
+
system "svn remove log/*"
|
102
|
+
puts "ignoring log directory"
|
103
|
+
system "svn propset svn:ignore '*.log' log/"
|
104
|
+
system "svn update log/"
|
105
|
+
puts "removing contents of tmp sub-directorys from svn"
|
106
|
+
system "svn remove tmp/cache/*"
|
107
|
+
system "svn remove tmp/pids/*"
|
108
|
+
system "svn remove tmp/sessions/*"
|
109
|
+
system "svn remove tmp/sockets/*"
|
110
|
+
puts "ignoring tmp directory"
|
111
|
+
system "svn propset svn:ignore '*' tmp/cache"
|
112
|
+
system "svn propset svn:ignore '*' tmp/pids"
|
113
|
+
system "svn propset svn:ignore '*' tmp/sessions"
|
114
|
+
system "svn propset svn:ignore '*' tmp/sockets"
|
115
|
+
system "svn update tmp/"
|
116
|
+
puts "committing changes"
|
117
|
+
system "svn commit -m 'Removed and ignored log files and tmp'"
|
118
|
+
end
|
119
|
+
|
120
|
+
# desc "Cache svn name and password on the server. Useful for http-based repositories."
|
121
|
+
task :cache_credentials do
|
122
|
+
run_with_input "svn list #{repository}"
|
123
|
+
end
|
124
|
+
|
125
|
+
desc "create backup of trac repository"
|
126
|
+
task :backup, :roles => :scm do
|
127
|
+
# http://svnbook.red-bean.com/nightly/en/svn.reposadmin.maint.html#svn.reposadmin.maint.backup
|
128
|
+
# XXX do we need this? insane!
|
129
|
+
# echo "REPOS_BASE=/var/svn" > ~/.svntoolsrc
|
130
|
+
DATE=`date +%Y%m%d-%a`
|
131
|
+
|
132
|
+
timestamp = Time.now.strftime("%Y%m%d-%a")
|
133
|
+
deprec2.mkdir(svn_backup_dir, :owner => :root, :group => :deploy, :mode => 0775, :via => :sudo)
|
134
|
+
dest_dir = File.join(svn_backup_dir, "#{application}_#{timestamp}")
|
135
|
+
sudo "svnadmin hotcopy #{repos_root} #{dest_dir}"
|
136
|
+
end
|
45
137
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
# XXX requires apache to have already been installed...
|
62
|
-
desc "install Subversion version control system"
|
63
|
-
task :svn_install, :roles => :scm do
|
64
|
-
# svn 1.4 server improves on 1.3 and is backwards compatible with 1.3 clients
|
65
|
-
# http://subversion.tigris.org/svn_1.4_releasenotes.html
|
66
|
-
#
|
67
|
-
# We're using FSFS instead of BerkeleyDB. Read why below:
|
68
|
-
# http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.reposadmin.basics.backends
|
69
|
-
#
|
70
|
-
# NOTE: we're bulding the python bindings for trac
|
71
|
-
# ./subversion/bindings/swig/INSTALL
|
72
|
-
#
|
73
|
-
version = 'subversion-1.4.4'
|
74
|
-
set :src_package, {
|
75
|
-
:file => version + '.tar.gz',
|
76
|
-
:md5sum => '702655defa418bab8f683f6268b4fd30 subversion-1.4.4.tar.gz',
|
77
|
-
:dir => version,
|
78
|
-
:url => "http://subversion.tigris.org/downloads/#{version}.tar.gz",
|
79
|
-
:unpack => "tar zxf #{version}.tar.gz;",
|
80
|
-
:configure => %w(
|
81
|
-
./configure
|
82
|
-
--prefix=/usr/local
|
83
|
-
--with-apxs=/usr/local/apache2/bin/apxs
|
84
|
-
--with-apr=/usr/local/apache2
|
85
|
-
--with-apr-util=/usr/local/apache2
|
86
|
-
PYTHON=/usr/bin/python
|
87
|
-
;
|
88
|
-
).reject{|arg| arg.match '#'}.join(' ') , # DRY this up
|
89
|
-
:make => 'make;',
|
90
|
-
:install => 'make install;',
|
91
|
-
:post_install => '
|
92
|
-
make swig-py;
|
93
|
-
make install-swig-py;
|
94
|
-
echo /usr/local/lib/svn-python > /usr/lib/python2.4/site-packages/subversion.pth;
|
95
|
-
'
|
96
|
-
}
|
97
|
-
enable_universe
|
98
|
-
apt.install( {:base => %w(libneon25 libneon25-dev swig python-dev)}, :stable )
|
99
|
-
deprec.download_src(src_package, src_dir)
|
100
|
-
deprec.install_from_src(src_package, src_dir)
|
101
|
-
end
|
102
|
-
|
103
|
-
desc "grant a user access to svn repos"
|
104
|
-
task :svn_grant_user_access, :roles => :scm do
|
105
|
-
deprec.useradd(svn_account)
|
106
|
-
deprec.groupadd(scm_group)
|
107
|
-
deprec.add_user_to_group(svn_account, scm_group)
|
108
|
-
end
|
109
|
-
|
110
|
-
desc "Create subversion repository and import project into it"
|
111
|
-
task :svn_setup, :roles => :scm do
|
112
|
-
svn_create_repos
|
113
|
-
svn_import
|
114
|
-
end
|
115
|
-
|
116
|
-
task :scm_setup, :roles => :scm do # deprecated
|
117
|
-
svn_setup
|
118
|
-
end
|
119
|
-
|
120
|
-
task :svn_import_project, :roles => :scm do # deprecated
|
121
|
-
svn_setup
|
122
|
-
end
|
123
|
-
|
124
|
-
desc "Create a subversion repository"
|
125
|
-
task :svn_create_repos, :roles => :scm do
|
126
|
-
set :svn_account, user
|
127
|
-
svn_grant_user_access
|
128
|
-
deprec.mkdir(repos_root, :mode => '2775', :group => scm_group)
|
129
|
-
sudo "svnadmin verify #{repos_root} > /dev/null 2>&1 || sudo svnadmin create #{repos_root}"
|
130
|
-
sudo "chmod -R g+w #{repos_root}"
|
131
|
-
end
|
132
|
-
|
133
|
-
# Adapted from code in Bradley Taylors RailsMachine gem
|
134
|
-
desc "Import project into subversion repository."
|
135
|
-
task :svn_import, :roles => :scm do
|
136
|
-
new_path = "../#{application}"
|
137
|
-
tags = repository.sub("trunk", "tags")
|
138
|
-
branches = repository.sub("trunk", "branches")
|
139
|
-
puts "Adding branches and tags"
|
140
|
-
system "svn mkdir -m 'Adding tags and branches directories' #{tags} #{branches}"
|
141
|
-
puts "Importing application."
|
142
|
-
system "svn import #{repository} -m 'Import'"
|
143
|
-
cwd = Dir.getwd
|
144
|
-
puts "Moving application to new directory"
|
145
|
-
Dir.chdir '../'
|
146
|
-
system "mv #{cwd} #{cwd}.imported"
|
147
|
-
puts "Checking out application."
|
148
|
-
system "svn co #{repository} #{application}"
|
149
|
-
Dir.chdir application
|
150
|
-
svn_remove_log_and_tmp
|
151
|
-
puts "Your repository is: #{repository}"
|
152
|
-
end
|
153
|
-
|
154
|
-
# Lifted from Bradley Taylors RailsMachine gem
|
155
|
-
desc "remove and ignore log files and tmp from subversion"
|
156
|
-
task :svn_remove_log_and_tmp, :roles => :scm do
|
157
|
-
puts "removing log directory contents from svn"
|
158
|
-
system "svn remove log/*"
|
159
|
-
puts "ignoring log directory"
|
160
|
-
system "svn propset svn:ignore '*.log' log/"
|
161
|
-
system "svn update log/"
|
162
|
-
puts "removing contents of tmp sub-directorys from svn"
|
163
|
-
system "svn remove tmp/cache/*"
|
164
|
-
system "svn remove tmp/pids/*"
|
165
|
-
system "svn remove tmp/sessions/*"
|
166
|
-
system "svn remove tmp/sockets/*"
|
167
|
-
puts "ignoring tmp directory"
|
168
|
-
system "svn propset svn:ignore '*' tmp/cache"
|
169
|
-
system "svn propset svn:ignore '*' tmp/pids"
|
170
|
-
system "svn propset svn:ignore '*' tmp/sessions"
|
171
|
-
system "svn propset svn:ignore '*' tmp/sockets"
|
172
|
-
system "svn update tmp/"
|
173
|
-
puts "committing changes"
|
174
|
-
system "svn commit -m 'Removed and ignored log files and tmp'"
|
175
|
-
end
|
176
|
-
|
177
|
-
# desc "Cache svn name and password on the server. Useful for http-based repositories."
|
178
|
-
task :svn_cache_credentials do
|
179
|
-
run_with_input "svn list #{repository}"
|
138
|
+
task :restore, :roles => :scm do
|
139
|
+
# prompt user to select from list of locally stored backups
|
140
|
+
# tracd_stop
|
141
|
+
# copy out backup
|
142
|
+
end
|
143
|
+
|
144
|
+
|
145
|
+
# XXX TODO
|
146
|
+
# desc "backup repository"
|
147
|
+
# task :svn_backup_respository, :roles => :scm do
|
148
|
+
# puts "read http://svnbook.red-bean.com/nightly/en/svn-book.html#svn.reposadmin.maint.backup"
|
149
|
+
# end
|
150
|
+
|
151
|
+
end
|
180
152
|
end
|
181
|
-
|
153
|
+
end
|
182
154
|
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
155
|
+
# svnserve setup
|
156
|
+
# I've previously used ssh exclusively I've decided svnserve is a reasonable choice for collaboration on open source projects.
|
157
|
+
# It's easier to setup than apache/ssl webdav access.
|
158
|
+
#
|
159
|
+
# sudo useradd svn
|
160
|
+
# sudo mkdir -p /var/svn/deprec_svnserve_root
|
161
|
+
# sudo ln -sf /var/www/apps/deprec/repos /var/svn/deprec_svnserve_root/deprec
|
162
|
+
# sudo chown -R svn /var/svn/deprec_svnserve_root/deprec
|
190
163
|
|
191
|
-
|
164
|
+
#
|
165
|
+
# XXX put password file into svn and command to push it
|
166
|
+
#
|
167
|
+
# # run svnserve
|
168
|
+
# sudo -u svn svnserve --daemon --root /var/svn/deprec_svnserve_root
|
169
|
+
#
|
170
|
+
# # check it out now
|
171
|
+
# svn co svn://scm.deprecated.org/deprec/trunk deprec
|
data/lib/deprec/recipes/trac.rb
CHANGED
@@ -1,100 +1,277 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
# Copyright 2006-2008 by Mike Bailey. All rights reserved.
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :deprec do namespace :trac do
|
4
|
+
|
5
|
+
# Master tracd process for server
|
6
|
+
set :tracd_cmd, '/usr/bin/tracd'
|
5
7
|
set :tracd_port, '9000'
|
6
|
-
set
|
7
|
-
|
8
|
-
|
9
|
-
set
|
10
|
-
|
11
|
-
|
8
|
+
set :tracd_pidfile, '/var/run/tracd.pid'
|
9
|
+
|
10
|
+
# Settings for this projects trac instance
|
11
|
+
set(:tracd_domain_root) { domain.sub(/.*?\./,'') } # strip subdomain from domain
|
12
|
+
set(:tracd_vhost_domain) { "trac-#{application}.#{tracd_domain_root}" } # nginx will proxy this domain to tracd
|
13
|
+
|
14
|
+
set(:trac_backup_dir) { "#{backup_dir}/trac" }
|
15
|
+
set(:trac_path) { exists?(:deploy_to) ? "#{deploy_to}/trac" : Capistrano::CLI.ui.ask('path to trac config') }
|
16
|
+
set(:tracd_parent_dir) { "/etc/trac.d" }
|
17
|
+
set(:trac_password_file) { "#{trac_path}/conf/users.htdigest" }
|
18
|
+
set(:trac_account) { Capistrano::CLI.prompt('enter new trac user account name') }
|
12
19
|
set :trac_passwordfile_exists, true # hack - should check on remote system instead
|
20
|
+
set(:trac_header_logo_link) { trac_home_url }
|
21
|
+
# We will symlink each projects trac dir into this dir for tracd to find
|
22
|
+
|
23
|
+
# project
|
24
|
+
set(:trac_domain) { domain.sub(/^.*?\./, 'trac.') }
|
25
|
+
set(:trac_home_url) { "http://#{trac_domain}/" }
|
26
|
+
set(:trac_desc) { application }
|
13
27
|
|
28
|
+
# Settings only used for generating trac.ini for this project
|
29
|
+
# - notification
|
30
|
+
set :trac_always_notify_owner, false
|
31
|
+
set :trac_always_notify_reporter, false
|
32
|
+
set :trac_always_notify_updater, true
|
33
|
+
set :trac_smtp_always_bcc, ''
|
34
|
+
set :trac_smtp_always_cc, ''
|
35
|
+
set :trac_smtp_default_domain, ''
|
14
36
|
set :trac_smtp_enabled, true
|
37
|
+
set :trac_smtp_from, 'trac@localhost'
|
38
|
+
set :trac_smtp_password, ''
|
39
|
+
set :trac_smtp_port, 25
|
40
|
+
set :trac_smtp_replyto, 'trac@localhost'
|
41
|
+
set :trac_smtp_server, 'localhost'
|
42
|
+
set :trac_smtp_subject_prefix, '__default__'
|
43
|
+
set :trac_smtp_user, ''
|
44
|
+
set :trac_use_public_cc, false
|
45
|
+
set :trac_use_short_addr, false
|
46
|
+
set :trac_use_tls, false
|
47
|
+
# - other
|
48
|
+
set(:trac_base_url) { trac_home_url }
|
49
|
+
|
50
|
+
desc "Install trac on server"
|
51
|
+
task :install, :roles => :scm do
|
52
|
+
install_deps
|
53
|
+
sudo "easy_install Trac==0.11rc1"
|
54
|
+
create_pid_dir
|
55
|
+
create_parent_dir
|
56
|
+
config_gen_system
|
57
|
+
config_system
|
58
|
+
activate_system
|
59
|
+
end
|
60
|
+
|
61
|
+
task :install_deps do
|
62
|
+
apt.install( {:base => %w(sqlite3 python-setuptools python-subversion)}, :stable )
|
63
|
+
end
|
64
|
+
|
65
|
+
# The start script has a couple of config values in it.
|
66
|
+
# We may want to extract them into a config file later
|
67
|
+
# and install this script as part of the :install task.
|
68
|
+
SYSTEM_CONFIG_FILES[:trac] = [
|
69
|
+
{:template => 'tracd-init.erb',
|
70
|
+
:path => '/etc/init.d/tracd',
|
71
|
+
:mode => 0755,
|
72
|
+
:owner => 'root:root'}
|
73
|
+
]
|
74
|
+
|
75
|
+
PROJECT_CONFIG_FILES[:trac] = [
|
76
|
+
{:template => 'users.htdigest.erb',
|
77
|
+
:path => "conf/users.htdigest",
|
78
|
+
:mode => 0644,
|
79
|
+
:owner => 'root:root'},
|
80
|
+
|
81
|
+
{:template => 'trac.ini.erb',
|
82
|
+
:path => "conf/trac.ini",
|
83
|
+
:mode => 0644,
|
84
|
+
:owner => 'root:root'},
|
85
|
+
|
86
|
+
{:template => 'nginx_vhost.conf.erb',
|
87
|
+
:path => "conf/nginx_vhost.conf",
|
88
|
+
:mode => 0644,
|
89
|
+
:owner => 'root:root'}
|
90
|
+
]
|
91
|
+
|
92
|
+
desc "Generate config files for trac"
|
93
|
+
task :config_gen do
|
94
|
+
config_gen_system
|
95
|
+
config_gen_project
|
96
|
+
end
|
97
|
+
|
98
|
+
task :config_gen_system do
|
99
|
+
SYSTEM_CONFIG_FILES[:trac].each do |file|
|
100
|
+
deprec2.render_template(:trac, file)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
task :config_gen_project do
|
105
|
+
PROJECT_CONFIG_FILES[:trac].each do |file|
|
106
|
+
deprec2.render_template(:trac, file)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
desc "Push trac config files to server"
|
111
|
+
task :config, :roles => :scm do
|
112
|
+
config_system
|
113
|
+
config_project
|
114
|
+
restart
|
115
|
+
top.deprec.nginx.restart
|
116
|
+
end
|
117
|
+
|
118
|
+
task :config_system, :roles => :scm do
|
119
|
+
deprec2.push_configs(:trac, SYSTEM_CONFIG_FILES[:trac])
|
120
|
+
end
|
15
121
|
|
16
|
-
task :
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
deprec.download_src(src_package, src_dir)
|
29
|
-
deprec.install_from_src(src_package, src_dir)
|
30
|
-
end
|
31
|
-
|
32
|
-
task :trac_create_pid_dir, :roles => :scm do
|
33
|
-
deprec.mkdir(File.dirname(trac_pidfile))
|
34
|
-
end
|
35
|
-
|
36
|
-
task :trac_setup, :roles => :scm do
|
37
|
-
trac_init
|
38
|
-
trac_config
|
122
|
+
task :config_project, :roles => :scm do
|
123
|
+
deprec2.push_configs(:trac, PROJECT_CONFIG_FILES[:trac])
|
124
|
+
symlink_nginx_vhost
|
125
|
+
end
|
126
|
+
|
127
|
+
desc "Initialize the trac db for this project"
|
128
|
+
task :setup, :roles => :scm do
|
129
|
+
init
|
130
|
+
config_gen_project
|
131
|
+
config_project
|
132
|
+
activate_project
|
133
|
+
# set_default_permissions # XXX re-enable this
|
39
134
|
# create trac account for current user
|
40
135
|
set :trac_account, user
|
41
136
|
set :trac_passwordfile_exists, false # hack - should check on remote system instead
|
42
|
-
|
43
|
-
|
44
|
-
trac_create_pid_dir
|
137
|
+
# user_add # XXX re-enable
|
45
138
|
end
|
46
139
|
|
47
|
-
task :
|
48
|
-
|
49
|
-
|
140
|
+
task :init, :roles => :scm do
|
141
|
+
deprec2.mkdir(trac_path, :via => :sudo)
|
142
|
+
sudo "trac-admin #{trac_path} initenv #{application} sqlite:db/trac.db svn #{repos_root}"
|
50
143
|
end
|
51
144
|
|
52
|
-
task :
|
53
|
-
|
54
|
-
|
145
|
+
task :set_default_permissions, :roles => :scm do
|
146
|
+
anonymous_disable
|
147
|
+
authenticated_enable
|
55
148
|
end
|
56
149
|
|
57
|
-
|
58
|
-
|
59
|
-
|
150
|
+
task :start, :roles => :scm do
|
151
|
+
sudo "/etc/init.d/tracd start"
|
152
|
+
end
|
153
|
+
|
154
|
+
task :stop, :roles => :scm do
|
155
|
+
sudo "/etc/init.d/tracd stop"
|
60
156
|
end
|
61
157
|
|
62
|
-
|
63
|
-
|
64
|
-
|
158
|
+
task :restart, :roles => :scm do
|
159
|
+
stop
|
160
|
+
start
|
161
|
+
end
|
162
|
+
|
163
|
+
task :activate, :roles => :scm do
|
164
|
+
activate_system
|
165
|
+
activate_project
|
65
166
|
end
|
66
167
|
|
67
|
-
task :
|
68
|
-
|
168
|
+
task :activate_system, :roles => :scm do
|
169
|
+
sudo "update-rc.d tracd defaults"
|
69
170
|
end
|
70
171
|
|
71
|
-
task :
|
72
|
-
|
73
|
-
# XXX run "echo point your browser to http://$CAPISTRANO:HOST$:#{tracd_port}/trac"
|
74
|
-
auth_string = "--auth=*,#{trac_password_file},#{application}"
|
75
|
-
sudo "tracd #{auth_string} --daemonize --single-env --port=#{tracd_port} --pidfile=#{trac_pidfile} #{trac_path}"
|
172
|
+
task :activate_project, :roles => :scm do
|
173
|
+
symlink_project
|
76
174
|
end
|
77
175
|
|
78
|
-
task :
|
79
|
-
|
80
|
-
|
176
|
+
task :deactivate, :roles => :scm do
|
177
|
+
deactivate_system
|
178
|
+
deactivate_project
|
81
179
|
end
|
82
180
|
|
181
|
+
task :deactivate_system, :roles => :scm do
|
182
|
+
sudo "update-rc.d -f tracd remove"
|
183
|
+
end
|
184
|
+
|
185
|
+
task :deactivate_project, :roles => :scm do
|
186
|
+
unlink_project
|
187
|
+
unlink_nginx_vhost
|
188
|
+
restart
|
189
|
+
end
|
190
|
+
|
191
|
+
desc "Create backup of trac repository"
|
192
|
+
task :backup, :roles => :web do
|
193
|
+
# http://trac.edgewall.org/wiki/TracBackup
|
194
|
+
timestamp = Time.now.utc.strftime("%Y%m%d%H%M%S")
|
195
|
+
dest_dir = File.join(trac_backup_dir, "trac_#{application}_#{timestamp}")
|
196
|
+
sudo "trac-admin #{trac_path} hotcopy #{dest_dir}"
|
197
|
+
end
|
198
|
+
|
199
|
+
desc "Restore trac repository from backup"
|
200
|
+
task :restore, :roles => :web do
|
201
|
+
# prompt user to select from list of locally stored backups
|
202
|
+
# tracd_stop
|
203
|
+
# copy out backup
|
204
|
+
end
|
205
|
+
|
206
|
+
#
|
207
|
+
# Service specific tasks for end users
|
208
|
+
#
|
83
209
|
desc "create a trac user"
|
84
|
-
task :
|
210
|
+
task :user_add, :roles => :scm do
|
85
211
|
create_file = trac_passwordfile_exists ? '' : ' -c '
|
86
212
|
htdigest = '/usr/local/apache2/bin/htdigest'
|
87
213
|
# XXX check if htdigest file exists and add '-c' option if not
|
88
214
|
# sudo "test -f #{trac_path/conf/users.htdigest}
|
89
215
|
create_file = trac_passwordfile_exists ? '' : ' -c '
|
90
|
-
sudo_with_input("#{htdigest} #{create_file} #{trac_path}/conf/users.htdigest #{application} #{trac_account}", /password:/)
|
216
|
+
deprec2.sudo_with_input("#{htdigest} #{create_file} #{trac_path}/conf/users.htdigest #{application} #{trac_account}", /password:/)
|
91
217
|
end
|
92
218
|
|
93
219
|
desc "list trac users"
|
94
|
-
task :
|
220
|
+
task :list_users, :roles => :scm do
|
95
221
|
sudo "cat #{trac_path}/conf/users.htdigest"
|
96
222
|
end
|
97
223
|
|
98
|
-
|
224
|
+
# desc "disable anonymous access to everything"
|
225
|
+
task :anonymous_disable, :roles => :scm do
|
226
|
+
sudo "trac-admin #{trac_path} permission remove anonymous '*'"
|
227
|
+
end
|
228
|
+
|
229
|
+
# desc "enable authenticated users access to everything"
|
230
|
+
task :authenticated_enable, :roles => :scm do
|
231
|
+
sudo "trac-admin #{trac_path} permission add authenticated TRAC_ADMIN"
|
232
|
+
end
|
233
|
+
|
234
|
+
#
|
235
|
+
# Helper tasks used by other tasks
|
236
|
+
#
|
237
|
+
|
238
|
+
# Link the trac repos for this project into the master trac repos dir
|
239
|
+
# We do this so we can use trac for multiple projects on the same server
|
240
|
+
task :symlink_project, :roles => :scm do
|
241
|
+
sudo "ln -sf #{trac_path} #{tracd_parent_dir}/#{application}"
|
242
|
+
end
|
243
|
+
|
244
|
+
task :unlink_project, :roles => :scm do
|
245
|
+
link = "#{tracd_parent_dir}/#{application}"
|
246
|
+
sudo "test -h #{link} && sudo unlink #{link} || true"
|
247
|
+
end
|
248
|
+
|
249
|
+
task :symlink_nginx_vhost, :roles => :scm do
|
250
|
+
sudo "ln -sf #{deploy_to}/trac/conf/nginx_vhost.conf #{nginx_vhost_dir}/tracd-#{application}.conf"
|
251
|
+
end
|
252
|
+
|
253
|
+
task :unlink_nginx_vhost, :roles => :scm do
|
254
|
+
link = "#{nginx_vhost_dir}/tracd-#{application}.conf"
|
255
|
+
sudo "test -h #{link} && unlink #{link} || true"
|
256
|
+
end
|
257
|
+
|
258
|
+
# task :symlink_apache_vhost, :roles => :scm do
|
259
|
+
# sudo "ln -sf #{deploy_to}/trac/conf/trac_apache_vhost.conf #{apache_vhost_dir}/#{application}-trac.conf"
|
260
|
+
# end
|
261
|
+
#
|
262
|
+
# task :unlink_apache_vhost, :roles => :scm do
|
263
|
+
# link = "#{apache_vhost_dir}/#{application}-trac.conf"
|
264
|
+
# sudo "test -h #{link} && unlink #{link} || true"
|
265
|
+
# end
|
266
|
+
|
267
|
+
task :create_pid_dir, :roles => :scm do
|
268
|
+
deprec2.mkdir(File.dirname(tracd_pidfile))
|
269
|
+
end
|
270
|
+
|
271
|
+
task :create_parent_dir, :roles => :scm do
|
272
|
+
deprec2.mkdir(tracd_parent_dir, :via => :sudo)
|
273
|
+
end
|
274
|
+
|
275
|
+
end end
|
99
276
|
|
100
277
|
end
|