yyyc514-dwell 0.1.99
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +19 -0
- data/README.txt +37 -0
- data/bin/dwell +3 -0
- data/lib/dwell/cap_extensions.rb +118 -0
- data/lib/dwell/known_hosts/github +1 -0
- data/lib/dwell/recipes/apache.rb +107 -0
- data/lib/dwell/recipes/bootstrap/linode.rb +75 -0
- data/lib/dwell/recipes/campfire.rb +55 -0
- data/lib/dwell/recipes/extras/daemontools.rb +57 -0
- data/lib/dwell/recipes/extras/php.rb +3 -0
- data/lib/dwell/recipes/extras/tinydns.rb +61 -0
- data/lib/dwell/recipes/gems.rb +33 -0
- data/lib/dwell/recipes/git.rb +25 -0
- data/lib/dwell/recipes/imagemagick.rb +26 -0
- data/lib/dwell/recipes/mercurial.rb +13 -0
- data/lib/dwell/recipes/mysql/base.rb +35 -0
- data/lib/dwell/recipes/mysql/db.rb +70 -0
- data/lib/dwell/recipes/mysql/helper.rb +19 -0
- data/lib/dwell/recipes/mysql.rb +4 -0
- data/lib/dwell/recipes/passenger.rb +45 -0
- data/lib/dwell/recipes/rails/app.rb +74 -0
- data/lib/dwell/recipes/rails/base.rb +91 -0
- data/lib/dwell/recipes/rails_app.rb +1 -0
- data/lib/dwell/recipes/ruby.rb +23 -0
- data/lib/dwell/recipes/sqlite.rb +14 -0
- data/lib/dwell/recipes/svn.rb +13 -0
- data/lib/dwell/recipes/ubuntu.rb +45 -0
- data/lib/dwell/recipes.rb +33 -0
- data/lib/dwell/templates/deploy.rb +47 -0
- data/lib/dwell/templates/passenger.conf +8 -0
- data/lib/dwell/templates/vhost.conf +48 -0
- data/lib/dwell/templates/vhost_ssl.conf +69 -0
- data/lib/dwell/ubuntu_extensions.rb +18 -0
- data/lib/dwell.rb +9 -0
- metadata +103 -0
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2008 Robert Bousquet <robert[at]robertbousquet[dot]com>
|
2
|
+
Copyright (c) 2008 Josh Goebel <dreamer3[at]gmail[dot]com>
|
3
|
+
|
4
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
5
|
+
of this software and associated documentation files (the "Software"), to
|
6
|
+
deal in the Software without restriction, including without limitation the
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
8
|
+
sell copies of the Software, and to permit persons to whom the Software is
|
9
|
+
furnished to do so, subject to the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be included in
|
12
|
+
all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
15
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
16
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
17
|
+
THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
18
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
19
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.txt
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
DWELL -- Capistrano recipe to setup a production Rails environment on Ubuntu.
|
2
|
+
|
3
|
+
|
4
|
+
1) Install Capistrano2 if you don't already have it:
|
5
|
+
$ sudo gem install capistrano
|
6
|
+
|
7
|
+
2) Build this gem:
|
8
|
+
$ gem build dwell.gemspec
|
9
|
+
|
10
|
+
3) Install gem with:
|
11
|
+
$ sudo gem install dwell-0.1.gem
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
USAGE
|
16
|
+
|
17
|
+
1) From within your Rails directory, run:
|
18
|
+
$ capify .
|
19
|
+
|
20
|
+
2) Click this link for recommended contents of config/deploy.rb:
|
21
|
+
http://pastie.org/private/lodo1zveqgc2i0rto9idw
|
22
|
+
|
23
|
+
3) Configure application name, domain, repository location and server name details
|
24
|
+
|
25
|
+
4) $ cap dwell:install
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
STACK DETAILS
|
30
|
+
|
31
|
+
1) Updates Ubuntu sources and distro
|
32
|
+
2) Installs Apache2
|
33
|
+
3) Installs MySQL5
|
34
|
+
4) Installs Subversion and Git
|
35
|
+
5) Installs Ruby, RubyGems, Rails and Merb
|
36
|
+
6) Installs Passenger module for Apache2 and creates basic config
|
37
|
+
|
data/bin/dwell
ADDED
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'capistrano'
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
module Dwell1
|
5
|
+
|
6
|
+
def record_install(package)
|
7
|
+
dwell1.append_to_file_if_missing "/etc/dwell/install_log", package
|
8
|
+
end
|
9
|
+
|
10
|
+
def config_gsub(file, find, replace)
|
11
|
+
tmp="/tmp/#{File.basename(file)}"
|
12
|
+
get file, tmp
|
13
|
+
content=File.open(tmp).read
|
14
|
+
content.gsub!(find,replace)
|
15
|
+
put content, tmp
|
16
|
+
sudo "mv #{tmp} #{file}"
|
17
|
+
end
|
18
|
+
|
19
|
+
def append_to_file_if_missing(filename, value, options={})
|
20
|
+
# XXX sort out single quotes in 'value' - they'l break command!
|
21
|
+
# XXX if options[:requires_sudo] and :use_sudo then use sudo
|
22
|
+
sudo <<-END
|
23
|
+
sh -c '
|
24
|
+
grep -F "#{value}" #{filename} > /dev/null 2>&1 ||
|
25
|
+
echo "#{value}" >> #{filename}
|
26
|
+
'
|
27
|
+
END
|
28
|
+
end
|
29
|
+
|
30
|
+
def sudo_upload(from, to, options={}, &block)
|
31
|
+
top.upload from, "/tmp/#{File.basename(to)}", options, &block
|
32
|
+
sudo "mv /tmp/#{File.basename(to)} #{to}"
|
33
|
+
sudo "chmod #{options[:mode]} #{to}" if options[:mode]
|
34
|
+
sudo "chown #{options[:owner]} #{to}" if options[:owner]
|
35
|
+
end
|
36
|
+
|
37
|
+
def adduser(user, options={})
|
38
|
+
options[:shell] ||= '/bin/bash' # new accounts on ubuntu 6.06.1 have been getting /bin/sh
|
39
|
+
switches = '--disabled-password --gecos ""'
|
40
|
+
switches += " --shell=#{options[:shell]} " if options[:shell]
|
41
|
+
switches += ' --no-create-home ' if options[:nohome]
|
42
|
+
switches += " --ingroup #{options[:group]} " unless options[:group].nil?
|
43
|
+
invoke_command "grep '^#{user}:' /etc/passwd || sudo /usr/sbin/adduser #{user} #{switches}",
|
44
|
+
:via => run_method
|
45
|
+
end
|
46
|
+
|
47
|
+
# create directory if it doesn't already exist
|
48
|
+
# set permissions and ownership
|
49
|
+
# XXX move mode, path and
|
50
|
+
def mkdir(path, options={})
|
51
|
+
via = options.delete(:via) || :run
|
52
|
+
# XXX need to make sudo commands wrap the whole command (sh -c ?)
|
53
|
+
# XXX removed the extra 'sudo' from after the '||' - need something else
|
54
|
+
invoke_command "test -d #{path} || #{sudo if via == :sudo} mkdir -p #{path}"
|
55
|
+
invoke_command "chmod #{sprintf("%3o",options[:mode]||0755)} #{path}", :via => via if options[:mode]
|
56
|
+
invoke_command "chown -R #{options[:owner]} #{path}", :via => via if options[:owner]
|
57
|
+
# groupadd(options[:group], :via => via) if options[:group]
|
58
|
+
invoke_command "chgrp -R #{options[:group]} #{path}", :via => via if options[:group]
|
59
|
+
end
|
60
|
+
|
61
|
+
##
|
62
|
+
# Run a command and ask for input when input_query is seen.
|
63
|
+
# Sends the response back to the server.
|
64
|
+
#
|
65
|
+
# +input_query+ is a regular expression that defaults to /^Password/.
|
66
|
+
#
|
67
|
+
# Can be used where +run+ would otherwise be used.
|
68
|
+
#
|
69
|
+
# run_with_input 'ssh-keygen ...', /^Are you sure you want to overwrite\?/
|
70
|
+
|
71
|
+
def run_with_input(shell_command, input_query=/^Password/, response=nil)
|
72
|
+
handle_command_with_input(:run, shell_command, input_query, response)
|
73
|
+
end
|
74
|
+
|
75
|
+
##
|
76
|
+
# Run a command using sudo and ask for input when a regular expression is seen.
|
77
|
+
# Sends the response back to the server.
|
78
|
+
#
|
79
|
+
# See also +run_with_input+
|
80
|
+
#
|
81
|
+
# +input_query+ is a regular expression
|
82
|
+
|
83
|
+
def sudo_with_input(shell_command, input_query=/^Password/, response=nil)
|
84
|
+
handle_command_with_input(:sudo, shell_command, input_query, response)
|
85
|
+
end
|
86
|
+
|
87
|
+
def invoke_with_input(shell_command, input_query=/^Password/, response=nil)
|
88
|
+
handle_command_with_input(run_method, shell_command, input_query, response)
|
89
|
+
end
|
90
|
+
|
91
|
+
private
|
92
|
+
|
93
|
+
##
|
94
|
+
# Does the actual capturing of the input and streaming of the output.
|
95
|
+
#
|
96
|
+
# local_run_method: run or sudo
|
97
|
+
# shell_command: The command to run
|
98
|
+
# input_query: A regular expression matching a request for input: /^Please enter your password/
|
99
|
+
|
100
|
+
def handle_command_with_input(local_run_method, shell_command, input_query, response=nil)
|
101
|
+
send(local_run_method, shell_command, {:pty => true}) do |channel, stream, data|
|
102
|
+
logger.info data, channel[:host]
|
103
|
+
if data =~ input_query
|
104
|
+
if response
|
105
|
+
channel.send_data "#{response}\n"
|
106
|
+
else
|
107
|
+
response = ::Capistrano::CLI.password_prompt "#{data}"
|
108
|
+
channel.send_data "#{response}\n"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
end
|
116
|
+
|
117
|
+
Capistrano.plugin :dwell1, Dwell1
|
118
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
github.com,65.74.177.129 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'erb'
|
2
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
3
|
+
namespace :dwell do
|
4
|
+
namespace :apache do
|
5
|
+
|
6
|
+
set :apache_server_name, nil
|
7
|
+
# set :apache_conf, nil
|
8
|
+
set :apache_default_vhost, false
|
9
|
+
set :apache_ctl, "/etc/init.d/apache2"
|
10
|
+
set :apache_server_aliases, []
|
11
|
+
# set :apache_proxy_port, 8000
|
12
|
+
# set :apache_proxy_servers, 2
|
13
|
+
# set :apache_proxy_address, "127.0.0.1"
|
14
|
+
set :apache_ssl_enabled, false
|
15
|
+
set :apache_ssl_ip, "*"
|
16
|
+
set :apache_ssl_forward_all, false
|
17
|
+
|
18
|
+
desc "Install Apache"
|
19
|
+
task :install do
|
20
|
+
sudo "apt-get install apache2 apache2-threaded-dev -y"
|
21
|
+
dwell1.record_install "apache2"
|
22
|
+
end
|
23
|
+
|
24
|
+
# shorter form
|
25
|
+
task :setup do
|
26
|
+
site.setup
|
27
|
+
end
|
28
|
+
|
29
|
+
namespace :site do
|
30
|
+
|
31
|
+
desc "Configure site for apache"
|
32
|
+
task :setup do
|
33
|
+
set :apache_server_name, domain unless apache_server_name
|
34
|
+
server_aliases = []
|
35
|
+
server_aliases << "www.#{apache_server_name}" unless apache_server_name =~ /^www\./
|
36
|
+
server_aliases.concat apache_server_aliases
|
37
|
+
set :apache_server_aliases_array, server_aliases
|
38
|
+
|
39
|
+
# port 80
|
40
|
+
file = File.join(File.dirname(__FILE__), "../templates", "vhost.conf")
|
41
|
+
template = File.read(file)
|
42
|
+
buffer = ERB.new(template).result(binding)
|
43
|
+
# ssl
|
44
|
+
if apache_ssl_enabled
|
45
|
+
file = File.join(File.dirname(__FILE__), "../templates", "vhost_ssl.conf")
|
46
|
+
template = File.read(file)
|
47
|
+
buffer += ERB.new(template).result(binding)
|
48
|
+
end
|
49
|
+
|
50
|
+
put buffer, "/tmp/vhost"
|
51
|
+
sudo "mv /tmp/vhost /etc/apache2/sites-available/#{application}"
|
52
|
+
sudo "a2dissite default"
|
53
|
+
sudo "a2ensite #{application}"
|
54
|
+
# enable some modules we need
|
55
|
+
sudo "a2enmod rewrite"
|
56
|
+
sudo "a2enmod deflate"
|
57
|
+
sudo "a2enmod ssl" if apache_ssl_enabled
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Disable this site"
|
61
|
+
task :disable do
|
62
|
+
sudo "a2dissite #{application}"
|
63
|
+
end
|
64
|
+
|
65
|
+
end
|
66
|
+
|
67
|
+
task :copy_certs do
|
68
|
+
Dir.glob("config/dwell/ssl/*").each do |file|
|
69
|
+
basename=File.basename(file)
|
70
|
+
dwell1.sudo_upload file, "/etc/ssl/certs/#{basename}" if file=~/.crt/
|
71
|
+
if file=~/.key/
|
72
|
+
dwell1.sudo_upload file, "/etc/ssl/private/#{basename}", :mode => 0600, :owner => "root.admin"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# Control
|
78
|
+
|
79
|
+
desc "Start Apache"
|
80
|
+
task :start, :roles => :web do
|
81
|
+
sudo "#{apache_ctl} start"
|
82
|
+
end
|
83
|
+
|
84
|
+
desc "Stop Apache"
|
85
|
+
task :stop, :roles => :web do
|
86
|
+
sudo "#{apache_ctl} stop"
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Restart Apache"
|
90
|
+
task :restart, :roles => :web do
|
91
|
+
sudo "#{apache_ctl} restart"
|
92
|
+
end
|
93
|
+
|
94
|
+
desc "Reload Apache"
|
95
|
+
task :reload, :roles => :web do
|
96
|
+
sudo "#{apache_ctl} reload"
|
97
|
+
end
|
98
|
+
|
99
|
+
desc "Force Reload Apache"
|
100
|
+
task :force_reload, :roles => :web do
|
101
|
+
sudo "#{apache_ctl} force-reload"
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :linode do
|
4
|
+
|
5
|
+
task :create_deploy_user do
|
6
|
+
dwell1.adduser deploy_user, :group => "admin"
|
7
|
+
new_password = Capistrano::CLI.ui.ask("Enter password for #{deploy_user}:") { |q| q.echo = true }
|
8
|
+
dwell1.invoke_with_input("passwd #{deploy_user}", /UNIX password/, new_password)
|
9
|
+
end
|
10
|
+
|
11
|
+
task :copy_ssh_key do
|
12
|
+
dwell1.mkdir "/home/#{deploy_user}/.ssh", :mode => 0700, :owner => "#{deploy_user}.admin"
|
13
|
+
put File.read("config/dwell/authorized_keys/#{deploy_user}"), "/home/#{deploy_user}/.ssh/authorized_keys", :mode => 0600
|
14
|
+
sudo "chown #{deploy_user}.admin /home/#{deploy_user}/.ssh/authorized_keys"
|
15
|
+
end
|
16
|
+
|
17
|
+
task :disable_root_login do
|
18
|
+
dwell1.config_gsub "/etc/ssh/sshd_config", /^PermitRootLogin (.*)$/,"PermitRootLogin no"
|
19
|
+
sudo "/etc/init.d/ssh reload"
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "setup static ip address"
|
23
|
+
task :setup_static_ip do
|
24
|
+
ip,broadcast,mask,gateway=nil
|
25
|
+
run "/sbin/ifconfig eth0" do |channel, stream, data|
|
26
|
+
if data.match(/inet addr:([^ ]*) Bcast:([^ ]*) Mask:([^ ]*)/)
|
27
|
+
ip, broadcast, mask = $1, $2, $3
|
28
|
+
end
|
29
|
+
end
|
30
|
+
run "ip route" do |channel, stream, data|
|
31
|
+
gateway=$1 if data.match(/default via ([^ ]*) dev eth0/)
|
32
|
+
end
|
33
|
+
|
34
|
+
interface=<<-EOS
|
35
|
+
iface eth0 inet static
|
36
|
+
address #{ip}
|
37
|
+
netmask #{mask.strip}
|
38
|
+
broadcast #{broadcast}
|
39
|
+
gateway #{gateway}
|
40
|
+
EOS
|
41
|
+
dwell1.config_gsub "/etc/network/interfaces", "iface eth0 inet dhcp", interface
|
42
|
+
sudo "chown root:root /etc/network/interfaces"
|
43
|
+
sudo "/etc/init.d/networking restart"
|
44
|
+
# kill the dhcp client
|
45
|
+
sudo "pkill dhclient3"
|
46
|
+
end
|
47
|
+
|
48
|
+
desc "bootstrap linode box"
|
49
|
+
task :bootstrap do
|
50
|
+
set :deploy_user, user
|
51
|
+
auth_keys="config/dwell/authorized_keys/#{deploy_user}"
|
52
|
+
unless File.exist?(auth_keys)
|
53
|
+
puts "\n Please place authorized SSH keys for #{deploy_user} in:"
|
54
|
+
puts " #{auth_keys}\n\n"
|
55
|
+
exit
|
56
|
+
end
|
57
|
+
set :user, "root"
|
58
|
+
if ubuntu1.lsb_info[:distrib_codename]=="intrepid"
|
59
|
+
# for linode's slimmed down intrepid
|
60
|
+
run "addgroup admin"
|
61
|
+
dwell1.append_to_file_if_missing "/etc/sudoers", "%admin ALL=(ALL) ALL"
|
62
|
+
sudo "apt-get install ubuntu-standard -y"
|
63
|
+
end
|
64
|
+
create_deploy_user
|
65
|
+
copy_ssh_key
|
66
|
+
set :user, deploy_user
|
67
|
+
# test deploy login via ssh before we disable root login
|
68
|
+
sudo "echo"
|
69
|
+
disable_root_login
|
70
|
+
setup_static_ip
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
namespace :dwell do
|
4
|
+
namespace :campfire do
|
5
|
+
set :campfire, nil
|
6
|
+
# set :campfire, {
|
7
|
+
# :account => "campfireurl",
|
8
|
+
# :login => "user@email.com",
|
9
|
+
# :password => "blah",
|
10
|
+
# :ssl => true,
|
11
|
+
# :room => "Dwell Room"
|
12
|
+
# }
|
13
|
+
|
14
|
+
def campfire_bot
|
15
|
+
@bot ||= begin
|
16
|
+
svc=Tinder::Campfire.new(campfire[:account], {:ssl => campfire[:ssl]})
|
17
|
+
svc.login(campfire[:login],campfire[:password])
|
18
|
+
room=svc.find_room_by_name(campfire[:room])
|
19
|
+
room
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def speak(message)
|
24
|
+
return unless campfire
|
25
|
+
require 'tinder' unless defined?(Tinder)
|
26
|
+
campfire_bot.speak(message)
|
27
|
+
end
|
28
|
+
|
29
|
+
after "deploy:restart" do
|
30
|
+
speak "* #{application} has been restarted on #{domain.upcase}."
|
31
|
+
end
|
32
|
+
|
33
|
+
after "app:stop" do
|
34
|
+
speak "* #{application} has been stopped on #{domain.upcase}."
|
35
|
+
end
|
36
|
+
|
37
|
+
after "app:start" do
|
38
|
+
speak "* #{application} has been started on #{domain.upcase}."
|
39
|
+
end
|
40
|
+
|
41
|
+
after "deploy" do
|
42
|
+
speak "* Revision ##{real_revision} has been deployed to #{domain.upcase}."
|
43
|
+
end
|
44
|
+
|
45
|
+
after "deploy:migrate" do
|
46
|
+
speak "* Migrations have been run on #{domain.upcase}."
|
47
|
+
end
|
48
|
+
|
49
|
+
after "deploy:cleanup" do
|
50
|
+
speak "* Cleaning old deploys from #{domain.upcase}."
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :daemontools do
|
4
|
+
|
5
|
+
task :add_intrepid_sources do
|
6
|
+
dwell1.append_to_file_if_missing "/etc/apt/sources.list",
|
7
|
+
"deb-src http://archive.ubuntu.com/ubuntu intrepid main restricted universe multiverse"
|
8
|
+
sudo "apt-get update"
|
9
|
+
end
|
10
|
+
|
11
|
+
task :build_from_source do
|
12
|
+
add_intrepid_sources
|
13
|
+
run "#{sudo} rm -rf tmp"
|
14
|
+
run "mkdir tmp"
|
15
|
+
run "cd tmp && #{sudo} apt-get -b source -t intrepid daemontools-run"
|
16
|
+
run "cd tmp && #{sudo} dpkg -i *.deb"
|
17
|
+
run "#{sudo} rm -rf tmp"
|
18
|
+
end
|
19
|
+
|
20
|
+
task :create_event_d do
|
21
|
+
cfg=<<-EOF
|
22
|
+
# svscan - daemontools
|
23
|
+
# https://bugs.launchpad.net/ubuntu/+source/daemontools-installer/+bug/66615
|
24
|
+
#
|
25
|
+
start on runlevel 2
|
26
|
+
start on runlevel 3
|
27
|
+
start on runlevel 4
|
28
|
+
start on runlevel 5
|
29
|
+
|
30
|
+
stop on runlevel 0
|
31
|
+
stop on runlevel 1
|
32
|
+
stop on runlevel 6
|
33
|
+
|
34
|
+
respawn
|
35
|
+
exec /usr/bin/svscanboot
|
36
|
+
EOF
|
37
|
+
put cfg, "/tmp/svscan"
|
38
|
+
sudo "mv /tmp/svscan /etc/event.d/svscan"
|
39
|
+
end
|
40
|
+
|
41
|
+
desc "Install daemontools"
|
42
|
+
task :install do
|
43
|
+
sudo "touch /etc/inittab" # install blows up if this file is not present
|
44
|
+
if ubuntu1.lsb_info[:distrib_codename]=="intrepid"
|
45
|
+
sudo "apt-get install daemontools daemontools-run -y"
|
46
|
+
else
|
47
|
+
puts "You are running #{ubuntu1.lsb_info[:DISTRIB_CODENAME]}. Building .debs from source."
|
48
|
+
build_from_source
|
49
|
+
end
|
50
|
+
create_event_d
|
51
|
+
sudo "initctl start svscan"
|
52
|
+
dwell1.record_install "daemontools"
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :tinydns do
|
4
|
+
|
5
|
+
task :add_intrepid_sources, :roles => :dns do
|
6
|
+
dwell1.append_to_file_if_missing "/etc/apt/sources.list",
|
7
|
+
"deb-src http://archive.ubuntu.com/ubuntu intrepid main restricted universe multiverse"
|
8
|
+
sudo "apt-get update"
|
9
|
+
end
|
10
|
+
|
11
|
+
task :build_from_source, :roles => :dns do
|
12
|
+
add_intrepid_sources
|
13
|
+
run "#{sudo} rm -rf tmp"
|
14
|
+
run "mkdir tmp"
|
15
|
+
run "cd tmp && #{sudo} apt-get -b source -t intrepid djbdns"
|
16
|
+
run "cd tmp && #{sudo} dpkg -i *.deb"
|
17
|
+
run "#{sudo} rm -rf tmp"
|
18
|
+
end
|
19
|
+
|
20
|
+
desc "Install daemontools"
|
21
|
+
task :install, :roles => :dns do
|
22
|
+
sudo "touch /etc/inittab" # install blows up if this file is not present
|
23
|
+
if ubuntu1.lsb_info[:distrib_codename]=="intrepid"
|
24
|
+
sudo "apt-get install djbdns -y"
|
25
|
+
else
|
26
|
+
puts "You are running #{ubuntu1.lsb_info[:distrib_codename]}. Building .debs from source."
|
27
|
+
sleep 2
|
28
|
+
build_from_source
|
29
|
+
end
|
30
|
+
dwell1.record_install "tinydns"
|
31
|
+
end
|
32
|
+
|
33
|
+
set :dns_ip, nil
|
34
|
+
|
35
|
+
task :setup, :roles => :dns do
|
36
|
+
if dns_ip.nil?
|
37
|
+
puts "Please set dns_ip in your deploy file to the IP of your DNS server."
|
38
|
+
exit
|
39
|
+
end
|
40
|
+
dwell1.adduser "tinydns", :nohome => true
|
41
|
+
sudo "tinydns-conf tinydns tinydns /etc/tinydns #{dns_ip}"
|
42
|
+
sudo "ln -s /etc/tinydns /etc/service"
|
43
|
+
sleep 2
|
44
|
+
run "svstat /etc/service/tinydns"
|
45
|
+
end
|
46
|
+
|
47
|
+
# control
|
48
|
+
|
49
|
+
desc "Start tinydns"
|
50
|
+
task :start, :roles => :dns do
|
51
|
+
sudo "svc -u /etc/service/tinydns"
|
52
|
+
end
|
53
|
+
|
54
|
+
desc "Stop tinydns"
|
55
|
+
task :stop, :roles => :dns do
|
56
|
+
sudo "svc -d /etc/service/tinydns"
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :gems do
|
4
|
+
|
5
|
+
set :rails_gem_version, nil
|
6
|
+
|
7
|
+
desc "Install RubyGems"
|
8
|
+
task :install_rubygems do
|
9
|
+
run "mkdir -p src"
|
10
|
+
run "cd src && wget http://rubyforge.org/frs/download.php/45905/rubygems-1.3.1.tgz"
|
11
|
+
run "cd src && tar xzf rubygems-1.3.1.tgz"
|
12
|
+
run "cd src/rubygems-1.3.1 && sudo ruby setup.rb"
|
13
|
+
run "sudo ln -sf /usr/bin/gem1.8 /usr/bin/gem"
|
14
|
+
run "cd ~/ && sudo rm -rf src"
|
15
|
+
dwell1.record_install "rubygems"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Install Gems"
|
19
|
+
task :install_gems do
|
20
|
+
sudo "gem install rails -v#{rails_gem_version} --no-rdoc --no-ri" if rails_gem_version
|
21
|
+
sudo "gem install rails capistrano rspec passenger mysql rdoc merb --no-rdoc --no-ri"
|
22
|
+
dwell1.record_install "default_gems"
|
23
|
+
end
|
24
|
+
|
25
|
+
desc "Installation"
|
26
|
+
task :install do
|
27
|
+
install_rubygems
|
28
|
+
install_gems
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :git do
|
4
|
+
|
5
|
+
desc "Install Git"
|
6
|
+
task :install do
|
7
|
+
sudo "apt-get install git-core curl gitweb git-svn -y"
|
8
|
+
dwell1.record_install "git"
|
9
|
+
end
|
10
|
+
|
11
|
+
before "deploy" do
|
12
|
+
return unless scm==:git
|
13
|
+
st=`git status`
|
14
|
+
if st=~/branch is ahead/ and not ENV['FORCE']
|
15
|
+
puts
|
16
|
+
puts " * Your local branch appears to be ahead of the remote. Do you need to push?"
|
17
|
+
puts " * You can force a deploy with FORCE=whatever if you wish."
|
18
|
+
puts
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :imagemagick do
|
4
|
+
|
5
|
+
desc "Install the ImageMagick binaries"
|
6
|
+
task :install_binary do
|
7
|
+
sudo "apt-get install imagemagick -y"
|
8
|
+
dwell1.record_install "imagemagick"
|
9
|
+
end
|
10
|
+
|
11
|
+
desc "Install gems for ImageMagick"
|
12
|
+
task :install_gems do
|
13
|
+
sudo "apt-get install libmagick++9-dev -y" # needed to build the rmagick gem
|
14
|
+
sudo "gem install rmagick mini_magick --no-rdoc --no-ri"
|
15
|
+
dwell1.record_install "gem: rmagick, mini_magick"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Install ImageMagick and gems"
|
19
|
+
task :install do
|
20
|
+
install_binary
|
21
|
+
install_gems
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :mercurial do
|
4
|
+
|
5
|
+
desc "Install Mercurial (hg)"
|
6
|
+
task :install do
|
7
|
+
sudo "apt-get install mercurial -y"
|
8
|
+
dwell1.record_install "mercurial"
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
namespace :dwell do
|
3
|
+
namespace :mysql do
|
4
|
+
|
5
|
+
desc "Install MySQL5"
|
6
|
+
task :install, :roles => :db do
|
7
|
+
sudo "DEBCONF_TERSE='yes' DEBIAN_PRIORITY='critical' DEBIAN_FRONTEND=noninteractive apt-get install -qyu --force-yes mysql-server mysql-client libmysqlclient15-dev"
|
8
|
+
dwell1.record_install "mysql5"
|
9
|
+
end
|
10
|
+
|
11
|
+
# control
|
12
|
+
|
13
|
+
desc "Start Mysql"
|
14
|
+
task :start, :roles => :db do
|
15
|
+
sudo "/etc/init.d/mysql start"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Stop Mysql"
|
19
|
+
task :stop, :roles => :db do
|
20
|
+
sudo "/etc/init.d/mysql stop"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "Restart Mysql"
|
24
|
+
task :restart, :roles => :db do
|
25
|
+
sudo "/etc/init.d/mysql restart"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Reload Mysql"
|
29
|
+
task :reload, :roles => :db do
|
30
|
+
sudo "/etc/init.d/mysql reload"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|