obbistrano 1.0.84 → 1.0.85
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/lib/obbistrano_tasks.rb +36 -46
- data/obbistrano.gemspec +1 -1
- metadata +1 -1
data/lib/obbistrano_tasks.rb
CHANGED
@@ -248,23 +248,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
248
248
|
|
249
249
|
|
250
250
|
|
251
|
-
|
252
|
-
# USER AND APPLICATION SETUP AND INITIALISATION
|
253
|
-
# =============================================================================
|
254
|
-
|
255
|
-
task :setup do
|
256
|
-
config_check
|
257
|
-
try_login
|
258
|
-
setup_mysql
|
259
|
-
vhost
|
260
|
-
ssh_key
|
261
|
-
end
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
251
|
+
|
268
252
|
# =============================================================================
|
269
253
|
# +MIGRATING+ APPLICATIONS
|
270
254
|
# =============================================================================
|
@@ -365,7 +349,37 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
365
349
|
s_namespace.setup_user
|
366
350
|
end
|
367
351
|
|
352
|
+
desc "Creates or gets an ssh key for the application"
|
353
|
+
task :ssh_key do
|
354
|
+
config_check
|
355
|
+
begin
|
356
|
+
run "cat .ssh/id_rsa.pub"
|
357
|
+
rescue
|
358
|
+
run "mkdir -p .ssh/"
|
359
|
+
run "ssh-keygen -t rsa -f .ssh/id_rsa -N ''"
|
360
|
+
run "cat .ssh/id_rsa.pub"
|
361
|
+
end
|
362
|
+
end
|
368
363
|
|
364
|
+
desc "Creates a MySQL user and database"
|
365
|
+
task :setup_mysql do
|
366
|
+
needs_root
|
367
|
+
set :user_to_add, "#{user}"
|
368
|
+
set :passwd_to_add, "#{password}"
|
369
|
+
with_user("root", "#{root_pass}") do
|
370
|
+
"#{databases}".each do |db|
|
371
|
+
begin
|
372
|
+
run "mysql -uroot -p#{root_pass} -e \"CREATE USER '#{user_to_add}'@'localhost' IDENTIFIED BY '#{passwd_to_add}';\""
|
373
|
+
run "mysql -uroot -p#{root_pass} -e 'CREATE DATABASE #{db}'"
|
374
|
+
run "musql -uroot -p#{root_pass} -e \"GRANT ALL PRIVILEGES ON `#{db}` . * TO '#{user_to_add}'@'localhost' IDENTIFIED BY '#{passwd_to_add}';\""
|
375
|
+
rescue
|
376
|
+
logger.info "Database #{db} already exists"
|
377
|
+
end
|
378
|
+
end
|
379
|
+
end
|
380
|
+
end
|
381
|
+
|
382
|
+
|
369
383
|
|
370
384
|
###### Private tasks for server operations #############
|
371
385
|
|
@@ -373,7 +387,7 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
373
387
|
config_setup
|
374
388
|
databases rescue set(:databases, ["#{application}"])
|
375
389
|
aliases rescue set(:aliases, []);
|
376
|
-
|
390
|
+
detect_os
|
377
391
|
end
|
378
392
|
|
379
393
|
task :needs_root do
|
@@ -396,38 +410,14 @@ Capistrano::Configuration.instance(:must_exist).load do
|
|
396
410
|
end
|
397
411
|
end
|
398
412
|
|
399
|
-
|
400
|
-
task :ssh_key do
|
401
|
-
config_check
|
402
|
-
begin
|
403
|
-
run "cat .ssh/id_rsa.pub"
|
404
|
-
rescue
|
405
|
-
run "mkdir -p .ssh/"
|
406
|
-
run "ssh-keygen -t rsa -f .ssh/id_rsa -N ''"
|
407
|
-
run "cat .ssh/id_rsa.pub"
|
408
|
-
end
|
409
|
-
end
|
410
|
-
|
411
|
-
desc "Creates a MySQL user and database"
|
412
|
-
task :setup_mysql do
|
413
|
-
needs_root
|
414
|
-
set :user_to_add, "#{user}"
|
415
|
-
set :passwd_to_add, "#{password}"
|
413
|
+
task :detect_os do
|
416
414
|
with_user("root", "#{root_pass}") do
|
417
|
-
"
|
418
|
-
|
419
|
-
run "mysql -uroot -p#{root_pass} -e \"CREATE USER '#{user_to_add}'@'localhost' IDENTIFIED BY '#{passwd_to_add}';\""
|
420
|
-
run "mysql -uroot -p#{root_pass} -e 'CREATE DATABASE #{db}'"
|
421
|
-
run "musql -uroot -p#{root_pass} -e \"GRANT ALL PRIVILEGES ON `#{db}` . * TO '#{user_to_add}'@'localhost' IDENTIFIED BY '#{passwd_to_add}';\""
|
422
|
-
rescue
|
423
|
-
logger.info "Database #{db} already exists"
|
424
|
-
end
|
425
|
-
end
|
415
|
+
if run "cat /etc/fedora_release" then server_type="fedora"
|
416
|
+
if run "cat /etc/debian_version" then server_type="ubuntu"
|
426
417
|
end
|
418
|
+
|
427
419
|
end
|
428
420
|
|
429
|
-
|
430
|
-
|
431
421
|
end
|
432
422
|
|
433
423
|
namespace :ubuntu do
|
data/obbistrano.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{obbistrano}
|
5
|
-
s.version = "1.0.
|
5
|
+
s.version = "1.0.85"
|
6
6
|
s.authors = ["Ross Riley", "One Black Bear"]
|
7
7
|
s.date = Time.now
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|