funkenplate 0.0.5 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +1 -1
- data/bin/funkenplate +3 -6
- data/lib/funkenplate.rb +49 -0
- data/lib/modules/capistrano.rb +123 -0
- data/lib/modules/database.rb +10 -0
- data/lib/modules/extensions.rb +17 -0
- data/lib/modules/finished.rb +1 -0
- data/lib/modules/general.rb +14 -0
- data/lib/modules/git.rb +37 -0
- data/lib/modules/secrets.rb +67 -0
- data/lib/string.rb +17 -0
- metadata +60 -41
- data/README.textile +0 -37
- data/funkenplate.rb +0 -263
- data/lib/dummy +0 -0
- data/templates/config/deploy/header.rb +0 -17
- data/templates/config/deploy/helper.rb +0 -53
- data/templates/config/deploy/options.rb +0 -19
- data/templates/config/deploy/repositories/fs.rb +0 -7
- data/templates/config/deploy/repositories/fs_remote_fs +0 -1
- data/templates/config/deploy/repositories/fs_remote_git +0 -1
- data/templates/config/deploy/repositories/github.rb +0 -5
- data/templates/config/deploy/repositories/github_remote +0 -1
- data/templates/config/deploy/tasks.rb +0 -116
- data/templates/config/initializers/directories.rb +0 -9
- data/templates/gitignore +0 -15
- data/templates/lib/core_extensions/array.rb +0 -9
- data/templates/lib/core_extensions/object.rb +0 -19
- data/templates/lib/core_extensions/string.rb +0 -7
- data/templates/lib/gem_extensions/formtastic.rb +0 -21
- data/templates/lib/rails_extensions/action_controller_base.rb +0 -37
- data/templates/lib/rails_extensions/action_controller_restful_test_case.rb +0 -56
- data/templates/lib/rails_extensions/active_record.rb +0 -5
- data/templates/lib/rails_extensions/application_helper.rb +0 -10
- data/templates/lib/restful.rb +0 -81
- data/templates/tmproj +0 -26
data/README.textile
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
h3. What is it?
|
2
|
-
|
3
|
-
A Rails 3 template for funkensturm. applications.
|
4
|
-
|
5
|
-
h3. Requirements
|
6
|
-
|
7
|
-
* Ruby >= @1.8.7@
|
8
|
-
* Rails >= @3.0.0@
|
9
|
-
|
10
|
-
h3. Installation
|
11
|
-
|
12
|
-
<pre>
|
13
|
-
gem install funkenplate
|
14
|
-
</pre>
|
15
|
-
|
16
|
-
h3. Online Usage
|
17
|
-
|
18
|
-
<pre>
|
19
|
-
rails myapp --template http://github.com/funkensturm/funkenplate/raw/master/funkenplate.rb
|
20
|
-
</pre>
|
21
|
-
|
22
|
-
h3. Offline Usage
|
23
|
-
|
24
|
-
Just hit this into your console and you will get the path to your local funkenplate template:
|
25
|
-
|
26
|
-
<pre>
|
27
|
-
funkenplate
|
28
|
-
</pre>
|
29
|
-
|
30
|
-
h3. Design guidelines
|
31
|
-
|
32
|
-
* Funkenplate works even when you are offline
|
33
|
-
|
34
|
-
h3. Assumptions
|
35
|
-
|
36
|
-
* The application is deployed to @/u/apps/APP@ where @APP@ stands for the name of the application you just created using funkenplate. If you need to change this, it is _safe_ to modify @deploy.rb@ afterwards without breaking any dependencies.
|
37
|
-
|
data/funkenplate.rb
DELETED
@@ -1,263 +0,0 @@
|
|
1
|
-
# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
|
2
|
-
# This template initializes a Rails app with git and capistrano
|
3
|
-
# for a repository located on the application server or github.
|
4
|
-
#
|
5
|
-
# Installation: sudo gem install funkenplate
|
6
|
-
# Online Usage: rails myapp --template http://github.com/funkensturm/funkenplate/raw/master/funkenplate.rb
|
7
|
-
# Offline Usage: rails myapp --template ~/.funkenplate/funkenplate.rb
|
8
|
-
# Documentation: http://github.com/funkensturm/funkenplate
|
9
|
-
# ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
|
10
|
-
|
11
|
-
# –––––––––––––––––––––
|
12
|
-
# Checking envirionment
|
13
|
-
# –––––––––––––––––––––
|
14
|
-
|
15
|
-
unless defined?(Rails)
|
16
|
-
puts %(This is not a standalone application, it is to be used as a template for Rails.)
|
17
|
-
exit 1
|
18
|
-
end
|
19
|
-
|
20
|
-
unless Gem.available?('funkenplate')
|
21
|
-
say_status :error, 'Please install the funkenplate gem first with "gem install funkenplate".', :red
|
22
|
-
exit 1
|
23
|
-
end
|
24
|
-
|
25
|
-
say_status :WELCOME, 'Welcome to funkenplate', :green
|
26
|
-
|
27
|
-
# –––––––––––––––––––––––––––
|
28
|
-
# OBTAINING GEM PATH AND LIBS
|
29
|
-
# –––––––––––––––––––––––––––
|
30
|
-
|
31
|
-
# Main paths
|
32
|
-
gem_path = Gem.source_index.find_name('funkenplate').last.full_gem_path
|
33
|
-
gem_version = Gem.source_index.find_name('funkenplate').last.version.version
|
34
|
-
templates_path = File.join(gem_path, 'templates')
|
35
|
-
|
36
|
-
# This is where we will search for funkenplate.yml containing individual secrets
|
37
|
-
secret_files = []
|
38
|
-
directories = ['..', ENV['HOME'], File.join(ENV['HOME'], '.ssh')]
|
39
|
-
files = ['funkenplate.yml', '.funkenplate.yml']
|
40
|
-
directories.each { |directory| files.each { |file| secret_files << File.expand_path(File.join(directory, file)) } }
|
41
|
-
|
42
|
-
# ––––––––––––––
|
43
|
-
# HELPER METHODS
|
44
|
-
# ––––––––––––––
|
45
|
-
|
46
|
-
def shout_status(*args)
|
47
|
-
puts
|
48
|
-
say_status(*args)
|
49
|
-
puts
|
50
|
-
end
|
51
|
-
|
52
|
-
def ask(question)
|
53
|
-
puts
|
54
|
-
say_status :QUESTION, question, :blue
|
55
|
-
print ' ' * 16
|
56
|
-
$stdin.gets.strip
|
57
|
-
end
|
58
|
-
|
59
|
-
def yes?(question)
|
60
|
-
answer = ask("#{question} (ENTER: yes)").downcase
|
61
|
-
puts
|
62
|
-
answer == '' or answer == "\n" or answer == 'y' or answer == 'yes' or answer == 'j' or answer == 'ja'
|
63
|
-
end
|
64
|
-
|
65
|
-
def read_template(file)
|
66
|
-
File.new(file).read
|
67
|
-
end
|
68
|
-
|
69
|
-
def apply_template(file)
|
70
|
-
read_template(file).
|
71
|
-
gsub('~app_name~', app_name).
|
72
|
-
gsub('~github_account~', @secrets[:deploy][:app_server][:user].to_s).
|
73
|
-
gsub('~domain~', @secrets[:deploy][:app_server][:domain].to_s).
|
74
|
-
gsub('~user~', @secrets[:deploy][:app_server][:user].to_s).
|
75
|
-
gsub('~port~', @secrets[:deploy][:app_server][:port].to_s).
|
76
|
-
gsub('~keys~', @secrets[:deploy][:app_server][:keys].to_s)
|
77
|
-
end
|
78
|
-
|
79
|
-
# –––––––––––––––
|
80
|
-
# DEFAULT SECRETS
|
81
|
-
# –––––––––––––––
|
82
|
-
|
83
|
-
# Default secrets
|
84
|
-
default_secrets = {
|
85
|
-
:version => gem_version,
|
86
|
-
:deploy => {
|
87
|
-
:app_server => {
|
88
|
-
:user => ENV['USER'].downcase,
|
89
|
-
:domain => 'YOUR_SERVER_DOMAIN_OR_IP_GOES_HERE',
|
90
|
-
:port => 22,
|
91
|
-
:keys => File.expand_path(File.join(ENV['HOME'], '.ssh', 'YOUR_PRIVATE_KEY'))
|
92
|
-
},
|
93
|
-
:github => {
|
94
|
-
:account => 'YOUR_GITHUB_ACCOUNT_NAME_GOES_HERE'
|
95
|
-
}
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
# –––––––––––––––––
|
100
|
-
# OBTAINING SECRETS
|
101
|
-
# –––––––––––––––––
|
102
|
-
|
103
|
-
@secrets = default_secrets
|
104
|
-
if secret_file = secret_files.find { |file| File.file? file }
|
105
|
-
@secrets = YAML.load_file secret_file
|
106
|
-
else
|
107
|
-
shout_status :error, "I could not find funkenplate.yml anywhere but I created one for you. You must edit it and then re-apply this template.", :red
|
108
|
-
say_status :info, "Note that you can put that yml file into any of these locations (top ones with higher priority):", :yellow
|
109
|
-
secret_files.each { |location| say_status '', " #{location}" }
|
110
|
-
shout_status :create, secret_files.first
|
111
|
-
File.open(secret_files.first, 'w') { |file| file.write YAML::dump(default_secrets) }
|
112
|
-
exit 1
|
113
|
-
end
|
114
|
-
|
115
|
-
shout_status :ENVIRONMENT, "These is the stuff we're working with here:", :yellow
|
116
|
-
print_table [
|
117
|
-
['Application name:', app_name],
|
118
|
-
['Application location:', destination_root],
|
119
|
-
['Funkenplate gem:', gem_path],
|
120
|
-
['Secret file:', secret_file],
|
121
|
-
], :ident => 16
|
122
|
-
|
123
|
-
shout_status :SECRETS, "I was able to obtain these secrets from the secret file:", :yellow
|
124
|
-
print_table [
|
125
|
-
['Application Server domain:', @secrets[:deploy][:app_server][:domain]],
|
126
|
-
['Application Server SSH user:', @secrets[:deploy][:app_server][:user]],
|
127
|
-
['Application Server SSH port:', @secrets[:deploy][:app_server][:port]],
|
128
|
-
['Github account:', @secrets[:deploy][:github][:account]],
|
129
|
-
['Location of your SSH key:', @secrets[:deploy][:app_server][:keys]],
|
130
|
-
], :ident => 16
|
131
|
-
|
132
|
-
unless yes?("Are these values correct?")
|
133
|
-
shout_status :EXITING, "OK, please edit this file first: #{secret_file}"
|
134
|
-
exit 1
|
135
|
-
end
|
136
|
-
|
137
|
-
# ––––––––––––––
|
138
|
-
# TEMPLATE TASKS
|
139
|
-
# ––––––––––––––
|
140
|
-
|
141
|
-
say_status :TASKS, 'Running template tasks...', :yellow
|
142
|
-
|
143
|
-
say_status :TASK, 'Clearing tmp directories...', :magenta
|
144
|
-
['tmp/pids', 'tmp/sessions', 'tmp/sockets', 'tmp/cache'].each { |dir| remove_file dir }
|
145
|
-
|
146
|
-
say_status :TASK, 'Creating additional directories...', :magenta
|
147
|
-
['private', 'lib/core_extensions', 'lib/rails_extensions'].each { |dir| empty_directory dir }
|
148
|
-
|
149
|
-
say_status :TASK, 'Deleting some boring files...', :magenta
|
150
|
-
['public/index.html', 'public/images/rails.png'].each { |dir| remove_file dir }
|
151
|
-
|
152
|
-
# ––––––––––––––
|
153
|
-
# TEMPLATE TASKS
|
154
|
-
# ––––––––––––––
|
155
|
-
|
156
|
-
say_status :TASK, 'Doing some beauty errands...', :magenta
|
157
|
-
run 'echo TODO > README'
|
158
|
-
run 'mv README README.textile'
|
159
|
-
|
160
|
-
say_status :TASK, 'Creating lib extensions...', :magenta
|
161
|
-
lib 'core_extensions/object.rb', read_template(File.join(templates_path, 'lib', 'core_extensions', 'object.rb'))
|
162
|
-
lib 'rails_extensions/active_record.rb', read_template(File.join(templates_path, 'lib', 'rails_extensions', 'active_record.rb'))
|
163
|
-
lib 'rails_extensions/action_controller_base.rb', read_template(File.join(templates_path, 'lib', 'rails_extensions', 'action_controller_base.rb'))
|
164
|
-
lib 'rails_extensions/application_helper.rb', read_template(File.join(templates_path, 'lib', 'rails_extensions', 'application_helper.rb'))
|
165
|
-
lib 'gem_extensions/formtastic.rb', read_template(File.join(templates_path, 'lib', 'gem_extensions', 'formtastic.rb'))
|
166
|
-
|
167
|
-
say_status :TASK, 'Creating initializer for lib extensions...', :magenta
|
168
|
-
initializer 'extensions.rb',
|
169
|
-
"Dir.glob(File.join(Rails.root, 'lib', 'core_extensions', '*.rb')) { |file| require file }\n
|
170
|
-
Dir.glob(File.join(Rails.root, 'lib', 'rails_extensions', '*.rb')) { |file| require file }\n
|
171
|
-
Dir.glob(File.join(Rails.root, 'lib', 'gem_extensions', '*.rb')) { |file| require file }\n"
|
172
|
-
|
173
|
-
say_status :TASK, 'Creating initializer for the private directory...', :magenta
|
174
|
-
initializer 'directory.rb', read_template(File.join(templates_path, 'config', 'initializers', 'directories.rb'))
|
175
|
-
|
176
|
-
say_status :TASK, 'Creating sample database.yml...', :magenta
|
177
|
-
file 'config/database.yml.sample', "
|
178
|
-
# HINT: If you are on the server, you might want to delete
|
179
|
-
# the \"development\" and \"test\" database definition in this file.
|
180
|
-
# This way you won't accidentally work on a development database.
|
181
|
-
#
|
182
|
-
\n\n#{File.new('config/database.yml').read}"
|
183
|
-
|
184
|
-
say_status :TASK, 'Creating TextMate project file...', :magenta
|
185
|
-
file "#{app_name}.tmproj", apply_template(File.join(templates_path, 'tmproj'))
|
186
|
-
|
187
|
-
say_status :TASK, 'Adding backtrace silencers...', :magenta
|
188
|
-
append_file 'config/initializers/backtrace_silencers.rb',
|
189
|
-
"Rails.backtrace_cleaner.add_silencer { |line| line =~ /^\s*passenger/ }"
|
190
|
-
|
191
|
-
# –––––––
|
192
|
-
# GIT
|
193
|
-
# –––––––
|
194
|
-
|
195
|
-
say_status :GIT, 'Gitifying application...', :yellow
|
196
|
-
|
197
|
-
say_status :GIT, 'Create .gitignore recursively in every empty directory...', :magenta
|
198
|
-
run 'find . \\( -type d -empty \\) -and \\( -not -regex ./\\.git.* \\) -exec touch {}/.gitignore \\;'
|
199
|
-
|
200
|
-
say_status :GIT, 'Create .gitignore in root...', :magenta
|
201
|
-
remove_file '.gitignore'
|
202
|
-
file '.gitignore', read_template(File.join(templates_path, 'gitignore'))
|
203
|
-
|
204
|
-
say_status :GIT, 'Initial commit...', :magenta
|
205
|
-
git :init
|
206
|
-
git :add => '.'
|
207
|
-
git :commit => "-a -m 'Initial commit.'"
|
208
|
-
|
209
|
-
say_status :GIT, 'Adding repository remotes for the fs server ...', :magenta
|
210
|
-
run "git remote add fs #{apply_template(File.join(templates_path, 'config', 'deploy', 'repositories', 'fs_remote_fs'))}"
|
211
|
-
run "git remote add fs.git #{apply_template(File.join(templates_path, 'config', 'deploy', 'repositories', 'fs_remote_git'))}"
|
212
|
-
|
213
|
-
# ––––––––––
|
214
|
-
# CAPISTRANO
|
215
|
-
# ––––––––––
|
216
|
-
|
217
|
-
say_status :CAPISTRANO, 'Capifying application...', :yellow
|
218
|
-
|
219
|
-
say_status :CAPISTRANO, 'Capify...', :magenta
|
220
|
-
capify!
|
221
|
-
|
222
|
-
say_status :CAPISTRANO, 'Backup original deploy.rb...', :magenta
|
223
|
-
run 'cp config/deploy.rb config/deploy.rb.sample'
|
224
|
-
|
225
|
-
deploy_header = [
|
226
|
-
apply_template(File.join(templates_path, 'config', 'deploy', 'header.rb')),
|
227
|
-
apply_template(File.join(templates_path, 'config', 'deploy', 'options.rb'))
|
228
|
-
].join("\n")
|
229
|
-
|
230
|
-
deploy_footer = [
|
231
|
-
apply_template(File.join(templates_path, 'config', 'deploy', 'tasks.rb')),
|
232
|
-
apply_template(File.join(templates_path, 'config', 'deploy', 'helper.rb'))
|
233
|
-
].join("\n")
|
234
|
-
|
235
|
-
say_status :CAPISTRANO, 'Generating deploy.fs.rb for repositories on fs server...', :magenta
|
236
|
-
file 'config/deploy.fs.rb', deploy_header + "\n" + apply_template(File.join(templates_path, 'config', 'deploy', 'repositories', 'fs.rb')) + "\n" + deploy_footer
|
237
|
-
|
238
|
-
say_status :CAPISTRANO, 'Generating deploy.github.rb for repositories on github.com...', :magenta
|
239
|
-
file 'config/deploy.github.rb', deploy_header + "\n" + apply_template(File.join(templates_path, 'config', 'deploy', 'repositories', 'github.rb')) + "\n" + deploy_footer
|
240
|
-
|
241
|
-
say_status :GIT, 'Commiting capistrano changes...', :magenta
|
242
|
-
git :add => '.'
|
243
|
-
git :commit => "-a -m 'Capified the app.'"
|
244
|
-
|
245
|
-
# –––––––––
|
246
|
-
# GEMS
|
247
|
-
# –––––––––
|
248
|
-
|
249
|
-
say_status :GEMFILE, 'Adding some gems...', :magenta
|
250
|
-
append_file "Gemfile", "
|
251
|
-
gem 'will_paginate'
|
252
|
-
gem 'formtastic'
|
253
|
-
gem 'geokit'
|
254
|
-
"
|
255
|
-
|
256
|
-
say_status :GIT, 'Commiting Gemfile changes...', :magenta
|
257
|
-
git :commit => "-a -m 'Added default gems to Gemfile.'"
|
258
|
-
|
259
|
-
# ––––––
|
260
|
-
# FINISH
|
261
|
-
# ––––––
|
262
|
-
|
263
|
-
shout_status :FINISHED, 'Congratulations.', :green
|
data/lib/dummy
DELETED
File without changes
|
@@ -1,17 +0,0 @@
|
|
1
|
-
# —————————————————————
|
2
|
-
# CAPISTRANO QUICKSTART
|
3
|
-
# —————————————————————
|
4
|
-
# cap deploy:check Dry check for permissions and so forth to mae sure you can deploy
|
5
|
-
# cap deploy:setup Create necessary directories
|
6
|
-
# cap deploy:cold Install application and run migrations
|
7
|
-
# cap deploy Update application
|
8
|
-
#
|
9
|
-
|
10
|
-
# ––––––––––––––––––
|
11
|
-
# APPLICATION SERVER
|
12
|
-
# ————————————————––
|
13
|
-
|
14
|
-
set :application, "~app_name~"
|
15
|
-
set :user, "~user~"
|
16
|
-
set :domain, "~domain~"
|
17
|
-
set :port, ~port~
|
@@ -1,53 +0,0 @@
|
|
1
|
-
# ———————————–––
|
2
|
-
# HELPER METHODS
|
3
|
-
# ————————————––
|
4
|
-
|
5
|
-
# Creates a bare git repository if needed and possible
|
6
|
-
def git_init(path)
|
7
|
-
return true if test_remote? :file, File.join(path, 'HEAD')
|
8
|
-
return false unless test_remote? :writable, path
|
9
|
-
run "cd #{path}; git --bare init"
|
10
|
-
test_remote?(:file, File.join(path, 'HEAD')) ? true : false
|
11
|
-
end
|
12
|
-
|
13
|
-
# Creates a directory only if needed and possible
|
14
|
-
def mkdir(path)
|
15
|
-
return true if test_remote? :directory, path
|
16
|
-
return false unless test_remote? :writable, '/' + path.split('/')[1..path.split('/').size-2].join('/')
|
17
|
-
run "mkdir #{path}"
|
18
|
-
test_remote?(:directory, path) ? true : false
|
19
|
-
end
|
20
|
-
|
21
|
-
# Performs various file tests on the remote server
|
22
|
-
def test_remote?(type, full_path)
|
23
|
-
arg = case type
|
24
|
-
when :file then '-f'
|
25
|
-
when :directory then '-d'
|
26
|
-
when :writable then '-w'
|
27
|
-
when :file_with_content then '-s'
|
28
|
-
end
|
29
|
-
'true' == capture("if [ #{arg} #{full_path} ]; then echo 'true'; fi").strip
|
30
|
-
end
|
31
|
-
|
32
|
-
# Returns the repository path if it is located on the deploy server
|
33
|
-
def repository_on_server?
|
34
|
-
return false unless repository =~ /^file/
|
35
|
-
repository.gsub('file://', '')
|
36
|
-
end
|
37
|
-
|
38
|
-
# Creates a directory in the shared path
|
39
|
-
def mkshared(path)
|
40
|
-
mkdir File.join(deploy_to, 'shared', path)
|
41
|
-
end
|
42
|
-
|
43
|
-
# Creates a symlink from <tt>deploy_to/shared/...</tt> to <tt>release_path/...</tt>
|
44
|
-
# If <tt>to</tt> is omitted, the release path mirrors in the shared path
|
45
|
-
def symlinker(from, to='')
|
46
|
-
to = from if to == ''
|
47
|
-
run "ln -nfs #{File.join deploy_to, 'shared', from} #{File.join release_path, to}"
|
48
|
-
end
|
49
|
-
|
50
|
-
# Quick helper for the database in the shared directory
|
51
|
-
def shared_database
|
52
|
-
File.join(deploy_to, 'shared', 'config', 'database.yml')
|
53
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# ––––––––––––––
|
2
|
-
# DEPLOY OPTIONS
|
3
|
-
# —————————————–
|
4
|
-
|
5
|
-
role :app, domain
|
6
|
-
role :web, domain
|
7
|
-
role :db, domain, :primary => true
|
8
|
-
|
9
|
-
set :scm, :git
|
10
|
-
set :use_sudo, false
|
11
|
-
set :keep_releases, 3
|
12
|
-
set :default_run_options, { :pty => true }
|
13
|
-
|
14
|
-
set :ssh_options, {
|
15
|
-
:forward_agent => true,
|
16
|
-
:paranoid => false,
|
17
|
-
:keys => ["~keys~"],
|
18
|
-
:port => port
|
19
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
fs:/home/git/repositories/~app_name~
|
@@ -1 +0,0 @@
|
|
1
|
-
fs.git:/home/git/repositories/~app_name~
|
@@ -1 +0,0 @@
|
|
1
|
-
git://github.com/~github_account~/~app_name~.git
|
@@ -1,116 +0,0 @@
|
|
1
|
-
# ———————————–––––—
|
2
|
-
# FUNKENPLATE HOOKS
|
3
|
-
# ————————————–––––
|
4
|
-
|
5
|
-
before 'deploy:setup', :funkenplate
|
6
|
-
after 'deploy:setup', 'deploy:setup_additions'
|
7
|
-
after 'deploy:update_code', 'deploy:additional_symlinks'
|
8
|
-
|
9
|
-
# ———————————–
|
10
|
-
# DEPLOY TASKS
|
11
|
-
# ————————————
|
12
|
-
|
13
|
-
namespace :quick do
|
14
|
-
|
15
|
-
# Quickly update git and deploy the app
|
16
|
-
desc 'Quick commit and deploy'
|
17
|
-
task :default do
|
18
|
-
system 'git add .; git add -u; git commit -m "cap quick"; git push origin master; cap deploy'
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
namespace :deploy do
|
24
|
-
|
25
|
-
# Manually restart for the Rails application
|
26
|
-
desc 'Restart passenger'
|
27
|
-
task :restart, :roles => :app, :except => { :no_release => true } do
|
28
|
-
run "touch #{File.join(current_path,'tmp','restart.txt')}"
|
29
|
-
end
|
30
|
-
|
31
|
-
# Happens after initial setup
|
32
|
-
desc "Add some more dirs into shared"
|
33
|
-
task :setup_additions do
|
34
|
-
mkshared 'private'
|
35
|
-
mkshared 'config'
|
36
|
-
run "touch #{shared_database}"
|
37
|
-
logger.important "REMEMBER TO EDIT #{shared_database} ON THE SERVER - NOT in THIS shell!" unless test_remote? :file_with_content, repository_on_server?
|
38
|
-
end
|
39
|
-
|
40
|
-
# Happens with each release
|
41
|
-
desc "Link in critical data from shared and install bundles"
|
42
|
-
task :additional_symlinks do
|
43
|
-
symlinker 'config/database.yml'
|
44
|
-
symlinker 'private'
|
45
|
-
run "cd #{release_path} && bundle install --without test"
|
46
|
-
end
|
47
|
-
|
48
|
-
# Overwriting default spin scripts
|
49
|
-
task :start do; end
|
50
|
-
task :stop do; end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
# ———————————––––––
|
55
|
-
# FUNKENPLATE TASKS
|
56
|
-
# ————————————–––––
|
57
|
-
|
58
|
-
namespace :funkenplate do
|
59
|
-
|
60
|
-
# Default run for funkenplate's pre-setup
|
61
|
-
task :default do
|
62
|
-
deploy_directory
|
63
|
-
remote_repository if repository_on_server? # i.e. if not github
|
64
|
-
end
|
65
|
-
|
66
|
-
# Creates the deploy_to directory (if possible)
|
67
|
-
task :deploy_directory do
|
68
|
-
mkdir deploy_to
|
69
|
-
unless test_remote? :directory, deploy_to
|
70
|
-
puts "\n-------------- DIRECTOY NOT FOUND --------------"
|
71
|
-
puts "Please run these commands as root on the server:"
|
72
|
-
puts "mkdir #{deploy_to}"
|
73
|
-
puts "chown #{user}:#{user} #{deploy_to}"
|
74
|
-
puts "------------------------------------------------\n\n"
|
75
|
-
exit
|
76
|
-
end
|
77
|
-
unless test_remote? :writable, deploy_to
|
78
|
-
puts "\n------------ DIRECTOY NOT WRITABLE -------------"
|
79
|
-
puts "Please run this command as root on the server:"
|
80
|
-
puts "chown #{user}:#{user} #{deploy_to} --recursive"
|
81
|
-
puts "------------------------------------------------\n\n"
|
82
|
-
exit
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
# Creates the repository if it is locally on the remote server
|
87
|
-
task :remote_repository do
|
88
|
-
mkdir repository_on_server?
|
89
|
-
unless test_remote? :directory, repository_on_server?
|
90
|
-
puts "\n-------- REPOSITORY ON SERVER NOT FOUND --------"
|
91
|
-
puts "Please run these commands as root on the server:"
|
92
|
-
puts "mkdir #{repository}"
|
93
|
-
puts "chown git:git #{repository}"
|
94
|
-
puts "------------------------------------------------\n\n"
|
95
|
-
exit
|
96
|
-
end
|
97
|
-
unless git_init repository_on_server?
|
98
|
-
puts "\n----- REPOSITORY ON SERVER NOT INITIALIZED -----"
|
99
|
-
puts "Please run these commands as root on the server:"
|
100
|
-
puts "cd #{repository}; git init --bare"
|
101
|
-
puts "chown git:git #{repository} --recursively"
|
102
|
-
puts "------------------------------------------------\n\n"
|
103
|
-
exit
|
104
|
-
end
|
105
|
-
unless test_remote? :file, File.join(repository_on_server?, 'refs', 'heads', 'master')
|
106
|
-
puts "\n-------- REPOSITORY ON SERVER IS EMPTY ---------"
|
107
|
-
puts "You need to do a local:"
|
108
|
-
puts "git push fs master (when using fs with your user)"
|
109
|
-
puts "git push fs.git master (when using fs with git user)"
|
110
|
-
puts "git push github master (when using github)"
|
111
|
-
puts "------------------------------------------------\n\n"
|
112
|
-
exit
|
113
|
-
end
|
114
|
-
end
|
115
|
-
|
116
|
-
end
|