fingercap 0.3.4 → 0.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/examples/fingercap.yml
CHANGED
@@ -0,0 +1,200 @@
|
|
1
|
+
require 'fingercap/recipes'
|
2
|
+
require 'fingercap/persistant_directory'
|
3
|
+
|
4
|
+
gem 'thinking-sphinx'
|
5
|
+
require 'thinking_sphinx/deploy/capistrano'
|
6
|
+
|
7
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
8
|
+
def _instances
|
9
|
+
if ENV['INSTANCE']
|
10
|
+
[ENV['INSTANCE']]
|
11
|
+
elsif ENV['INSTANCES']
|
12
|
+
ENV['INSTANCES'].split(' ')
|
13
|
+
elsif variables[:instances_file]
|
14
|
+
File.read(File.expand_path(variables[:instances_file], __FILE__)).split(/\s/).map { |i| i.strip }
|
15
|
+
else
|
16
|
+
puts "[!] Please set an :instances_file or pass the instances to operate on through INSTANCE or INSTANCES."
|
17
|
+
exit -1
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def install_from_secure(path, remote_file_name, options={})
|
22
|
+
sudo "scp #{remote_ssh_options} deploy@secure.callrecord.me:/home/deploy/#{path} #{remote_file_name}"
|
23
|
+
end
|
24
|
+
|
25
|
+
set :instances, _instances
|
26
|
+
set :primary_instance, instances.first
|
27
|
+
|
28
|
+
default_run_options[:pty] = true
|
29
|
+
|
30
|
+
set :runner, 'app'
|
31
|
+
set :user, 'deploy'
|
32
|
+
set :deploy_to, "/var/www/#{application}"
|
33
|
+
|
34
|
+
set :domain, primary_instance
|
35
|
+
role :app, *instances
|
36
|
+
role :web, *instances
|
37
|
+
role :db, primary_instance, :primary => true
|
38
|
+
|
39
|
+
set :remote_secure_key_file, '/home/deploy/.ssh/secure.key'
|
40
|
+
set :remote_ssh_options, "-o 'StrictHostKeyChecking no' -i #{remote_secure_key_file}"
|
41
|
+
|
42
|
+
if variables[:deploy_key_file]
|
43
|
+
if File.exist?(deploy_key_file)
|
44
|
+
ssh_options[:keys] = [deploy_key_file]
|
45
|
+
else
|
46
|
+
puts "[!] Can't read `#{deploy_key_file}', maybe certain volumes aren't mounted?"
|
47
|
+
exit -1
|
48
|
+
end
|
49
|
+
else
|
50
|
+
puts "[!] Please set :ssh_key_file with a path to a valid SSH key for the deploy user."
|
51
|
+
end
|
52
|
+
|
53
|
+
namespace :key do
|
54
|
+
desc "Push the secure SSH key to the instance"
|
55
|
+
task :push do
|
56
|
+
remote_secure_key_dir = File.dirname(remote_secure_key_file)
|
57
|
+
sudo "mkdir -p #{remote_secure_key_dir}"
|
58
|
+
sudo "chown -R deploy:deploy #{remote_secure_key_dir}"
|
59
|
+
sudo "rm -f #{remote_secure_key_file}"
|
60
|
+
upload(secure_key_file, remote_secure_key_file)
|
61
|
+
sudo "chmod 400 #{remote_secure_key_file}"
|
62
|
+
end
|
63
|
+
|
64
|
+
desc "Remove the secure SSH key from the instance"
|
65
|
+
task :remove do
|
66
|
+
sudo "rm -f #{remote_secure_key_file}"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
namespace :configure do
|
71
|
+
desc "Set permissions on the application install directories"
|
72
|
+
task :set_permissions do
|
73
|
+
try_sudo "chown -R #{user}:wheel #{deploy_to}"
|
74
|
+
try_sudo "chown -R #{fetch(:runner, "app")}:wheel #{shared_path}"
|
75
|
+
end
|
76
|
+
|
77
|
+
desc "Create persistant directories"
|
78
|
+
task :create_persistant_directories do
|
79
|
+
raise "Overwrite this task for the specific application"
|
80
|
+
end
|
81
|
+
|
82
|
+
desc "Symlink persistant directories"
|
83
|
+
task :symlink_persistant_directories do
|
84
|
+
raise "Overwrite this task for the specific application"
|
85
|
+
end
|
86
|
+
|
87
|
+
desc "Copy credentials from the secure instance to the shared directory"
|
88
|
+
task :install_credentials do
|
89
|
+
end
|
90
|
+
|
91
|
+
desc "Copy server certificates from the secure instance to /etc"
|
92
|
+
task :install_certificates do
|
93
|
+
# TODO: permissions
|
94
|
+
install_from_secure 'etc/ssl/private/callrecord.pem', '/etc/ssl/private/callrecord.pem'
|
95
|
+
install_from_secure 'etc/ssl/certs/robin.crt', '/etc/ssl/certs/robin.crt'
|
96
|
+
end
|
97
|
+
|
98
|
+
desc "Install all gems needed by the application"
|
99
|
+
task :install_gems do
|
100
|
+
sudo "gem install libxml-ruby --no-rdoc --no-ri"
|
101
|
+
run "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; sudo rake gems:install RAILS_ENV=production; fi"
|
102
|
+
end
|
103
|
+
|
104
|
+
desc "Setup additional networking"
|
105
|
+
task :networking do
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
namespace :monit do
|
110
|
+
desc "Restart services"
|
111
|
+
task :restart do
|
112
|
+
sudo "/usr/sbin/monit -c /etc/monitrc restart all"
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
namespace :sphinx do
|
117
|
+
desc "Stop Sphinx"
|
118
|
+
task :stop do
|
119
|
+
run "if [ -f #{current_path}/Rakefile ]; then cd #{current_path}; rake thinking_sphinx:stop RAILS_ENV=production; fi"
|
120
|
+
end
|
121
|
+
|
122
|
+
desc "Start the search daemon"
|
123
|
+
task :start do
|
124
|
+
thinking_sphinx.configure
|
125
|
+
thinking_sphinx.start
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
namespace :tunnel do
|
130
|
+
PID_FILE = '/var/run/ssh-tunnel.pid'
|
131
|
+
START_STOP_DAEMON = '/sbin/start-stop-daemon'
|
132
|
+
SSH = '/usr/bin/ssh'
|
133
|
+
|
134
|
+
desc "Setup SSH tunnels to the secure instance"
|
135
|
+
task :setup do
|
136
|
+
args = "#{remote_ssh_options} -L 35553:localhost:35553 deploy@depot.callrecord.me -N"
|
137
|
+
sudo "#{START_STOP_DAEMON} --make-pidfile --pidfile #{PID_FILE} --exec #{SSH} --background --start -- #{args} "
|
138
|
+
end
|
139
|
+
|
140
|
+
desc "Tear SSH tunnels to the secure instance down"
|
141
|
+
task :teardown do
|
142
|
+
sudo "echo"
|
143
|
+
run "if [ -f #{PID_FILE} ]; then sudo #{START_STOP_DAEMON} --pidfile #{PID_FILE} --stop; fi"
|
144
|
+
end
|
145
|
+
|
146
|
+
desc "Stop and start the tunnel"
|
147
|
+
task :restart do
|
148
|
+
tunnel.teardown
|
149
|
+
tunnel.setup
|
150
|
+
end
|
151
|
+
|
152
|
+
desc "Clean out the pidfile left by a crashed SSH tunnel"
|
153
|
+
task :cleanup do
|
154
|
+
sudo "rm -f #{PID_FILE}"
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
namespace :deploy do
|
159
|
+
desc "Stop the application (empty operation)"
|
160
|
+
task :stop do
|
161
|
+
end
|
162
|
+
|
163
|
+
desc "Start the application"
|
164
|
+
task :start do
|
165
|
+
apache.restart
|
166
|
+
end
|
167
|
+
|
168
|
+
desc "Restart the application"
|
169
|
+
task :restart do
|
170
|
+
passenger.restart
|
171
|
+
end
|
172
|
+
|
173
|
+
desc "Configure the instance for this application and install it"
|
174
|
+
task :install do
|
175
|
+
setup
|
176
|
+
configure.set_permissions
|
177
|
+
check
|
178
|
+
configure.create_persistant_directories
|
179
|
+
key.push
|
180
|
+
configure.install_credentials
|
181
|
+
configure.install_certificates
|
182
|
+
configure.networking
|
183
|
+
key.remove
|
184
|
+
update
|
185
|
+
configure.install_gems
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
after 'deploy:symlink', 'configure:symlink_persistant_directories'
|
190
|
+
|
191
|
+
if variables[:prepare_tasks]
|
192
|
+
before "deploy", *prepare_tasks
|
193
|
+
before "deploy:migrations", *prepare_tasks
|
194
|
+
end
|
195
|
+
|
196
|
+
if variables[:finalize_tasks]
|
197
|
+
after "deploy", *finalize_tasks
|
198
|
+
after "deploy:migrations", *finalize_tasks
|
199
|
+
end
|
200
|
+
end
|
@@ -12,8 +12,9 @@ module PersistantDirectory
|
|
12
12
|
# PersistantDirectory.create('public/icons', 'public/files')
|
13
13
|
def create(*args)
|
14
14
|
args.each do |directory|
|
15
|
-
|
16
|
-
|
15
|
+
sudo "mkdir -p #{shared_path}/#{directory}"
|
16
|
+
sudo "chown -R #{fetch(:runner, "app")}:wheel #{shared_path}"
|
17
|
+
sudo "chmod -R 775 #{shared_path}"
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fingercap
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 3
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
- 3
|
9
8
|
- 4
|
10
|
-
version: 0.
|
9
|
+
version: "0.4"
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Manfred Stienstra
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date: 2010-
|
17
|
+
date: 2010-09-10 00:00:00 +02:00
|
19
18
|
default_executable:
|
20
19
|
dependencies: []
|
21
20
|
|
@@ -31,6 +30,7 @@ extra_rdoc_files:
|
|
31
30
|
files:
|
32
31
|
- lib/fingercap/configurations/ec2.rb
|
33
32
|
- lib/fingercap/configurations/miller.rb
|
33
|
+
- lib/fingercap/configurations/recorder.rb
|
34
34
|
- lib/fingercap/persistant_directory.rb
|
35
35
|
- lib/fingercap/recipes/apache.rb
|
36
36
|
- lib/fingercap/recipes/notify.rb
|