traquitana 0.0.11 → 0.0.12
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/.gitignore +2 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +71 -0
- data/Rakefile +8 -0
- data/bin/traq +28 -5
- data/config/default.yml +7 -8
- data/config/extra.sh +1 -0
- data/config/nginx.sh +6 -0
- data/config/passenger.sh +6 -7
- data/config/proc.sh +37 -16
- data/config/traq.yml +25 -0
- data/lib/bar.rb +39 -0
- data/lib/cleaner.rb +17 -0
- data/lib/config.rb +44 -28
- data/lib/deployer.rb +59 -0
- data/lib/migrator.rb +25 -0
- data/lib/packager.rb +44 -0
- data/lib/selector.rb +24 -0
- data/lib/ssh.rb +43 -0
- data/lib/traquitana.rb +3 -0
- data/lib/traquitana/version.rb +3 -0
- data/spec/bar_spec.rb +45 -0
- data/spec/cleaner_spec.rb +22 -0
- data/spec/config/Gemfile +0 -0
- data/spec/config/Rakefile +0 -0
- data/spec/config/app/controllers/people_controller.rb +0 -0
- data/spec/config/app/models/people.rb +0 -0
- data/spec/config/app/views/people/index.html.erb +0 -0
- data/spec/config/app/views/people/show.html.erb +0 -0
- data/spec/config/config.ru +0 -0
- data/spec/config/config/application.rb +0 -0
- data/spec/config/config/environment.rb +0 -0
- data/spec/config/config/environments/production.rb +0 -0
- data/spec/config/config/initializers/inflections.rb +0 -0
- data/spec/config/config/initializers/mime_types.rb +0 -0
- data/spec/config/config/locales/en.yml +0 -0
- data/spec/config/config/locales/pt-BR.yml +0 -0
- data/spec/config/config/routes.rb +0 -0
- data/spec/config/config/traq.yml +25 -0
- data/spec/config/db/migrate/one.rb +0 -0
- data/spec/config/db/migrate/two.rb +0 -0
- data/spec/config/lib/test.rb +0 -0
- data/spec/config/network_test.txt +1 -0
- data/spec/config/public/images/one.jpg +0 -0
- data/spec/config/public/images/themes/dark/dark.jpg +0 -0
- data/spec/config/public/images/themes/theme.jpg +0 -0
- data/spec/config/public/images/three.jpg +0 -0
- data/spec/config/public/images/two.jpg +0 -0
- data/spec/config/public/images/uploads/avatars/avatar.jpg +0 -0
- data/spec/config/public/images/uploads/people/person.jpg +0 -0
- data/spec/config/public/images/uploads/upload.jpg +0 -0
- data/spec/config/public/javascripts/application.js +0 -0
- data/spec/config/public/stylesheets/application.css +0 -0
- data/spec/config_spec.rb +64 -0
- data/spec/deploy_spec.rb +11 -0
- data/spec/migrator_spec.rb +75 -0
- data/spec/network_spec.rb +56 -0
- data/spec/packager_spec.rb +44 -0
- data/spec/selector_spec.rb +14 -0
- data/traq/config.yml +25 -0
- data/traquitana.gemspec +21 -0
- metadata +109 -14
- data/lib/deploy.rb +0 -151
@@ -0,0 +1,56 @@
|
|
1
|
+
require "digest/md5"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
|
4
|
+
|
5
|
+
describe Traquitana::SSH do
|
6
|
+
before do
|
7
|
+
@config = Traquitana::Config.instance
|
8
|
+
@network = Traquitana::SSH.new(@config.host,@config.user)
|
9
|
+
@send = "#{File.expand_path(File.dirname(__FILE__))}/config/network_test.txt"
|
10
|
+
@md5 = Digest::MD5.hexdigest(File.read(@send))
|
11
|
+
|
12
|
+
Dir.mkdir(@config.directory) if !File.exists?(@config.directory)
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "configs" do
|
16
|
+
it "should have a host attribute" do
|
17
|
+
@network.must_respond_to(:host)
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should have an user attribute" do
|
21
|
+
@network.must_respond_to(:user)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should have an options attribute" do
|
25
|
+
@network.must_respond_to(:options)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
describe "operations" do
|
30
|
+
it "should have a send method" do
|
31
|
+
@network.must_respond_to(:send_files)
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should send a file to the remote host" do
|
35
|
+
check = "#{@config.directory}/#{File.basename(@send)}"
|
36
|
+
File.unlink(check) if File.exists?(check)
|
37
|
+
@network.send_files([[@send,"#{@config.directory}/#{File.basename(@send)}"]],Traquitana::Bar.new)
|
38
|
+
assert File.exists?(check)
|
39
|
+
Digest::MD5.hexdigest(File.read(check)).must_equal @md5
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should have a execute method" do
|
43
|
+
@network.must_respond_to(:execute)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should execute a command on the remote host" do
|
47
|
+
remote_dir = "#{@config.directory}/remote_dir"
|
48
|
+
FileUtils.rmdir(remote_dir) if File.exists?(remote_dir)
|
49
|
+
@network.execute(["mkdir #{@config.directory}/remote_dir"])
|
50
|
+
assert File.exists?(remote_dir)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
describe "uploading" do
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
|
4
|
+
|
5
|
+
describe Traquitana::Packager do
|
6
|
+
before do
|
7
|
+
@packager = Traquitana::Packager.new(File.expand_path(File.dirname(__FILE__))+"/config/")
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should have an id method" do
|
11
|
+
@packager.must_respond_to(:id)
|
12
|
+
end
|
13
|
+
|
14
|
+
it "should return an id" do
|
15
|
+
@packager.id.wont_be_nil
|
16
|
+
end
|
17
|
+
|
18
|
+
it "should have a list file method" do
|
19
|
+
@packager.must_respond_to(:list_file)
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should return the correct list file name" do
|
23
|
+
id = @packager.id
|
24
|
+
@packager.list_file.must_equal @packager.id+".list"
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should have a zip file method" do
|
28
|
+
@packager.must_respond_to(:zip_file)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should return the correct zip file name" do
|
32
|
+
id = @packager.id
|
33
|
+
@packager.zip_file.must_equal @packager.id+".zip"
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should have a pack method" do
|
37
|
+
@packager.must_respond_to(:pack)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should return the list and package file" do
|
41
|
+
list, package = @packager.pack
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require "fileutils"
|
2
|
+
require "minitest/autorun"
|
3
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/../lib/traquitana.rb"
|
4
|
+
|
5
|
+
describe Traquitana::Selector do
|
6
|
+
it "should have a selected files method" do
|
7
|
+
Traquitana::Selector.new.must_respond_to(:files)
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should return the file list" do
|
11
|
+
list = Traquitana::Selector.new(File.expand_path(File.dirname(__FILE__))+"/config/").files
|
12
|
+
list.size.must_equal 23
|
13
|
+
end
|
14
|
+
end
|
data/traq/config.yml
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Default configuration---
|
2
|
+
:directory: /tmp/traq_test
|
3
|
+
:ignore: 24
|
4
|
+
:user: taq
|
5
|
+
:list:
|
6
|
+
- Rakefile
|
7
|
+
- config.ru
|
8
|
+
- Gemfile
|
9
|
+
- - config/application.rb
|
10
|
+
- - config/environment.rb
|
11
|
+
- - config/initializers/**/*
|
12
|
+
- - config/environments/production.rb
|
13
|
+
- - config/locales/**/*
|
14
|
+
- - config/routes.rb
|
15
|
+
- - app/**/*
|
16
|
+
- - db/migrate/**/*
|
17
|
+
- - public/javascripts/**/*
|
18
|
+
- - public/stylesheets/**/*
|
19
|
+
- - lib/**/*
|
20
|
+
- - public/images/**/*
|
21
|
+
- public/images/uploads/**/*
|
22
|
+
:password: fill your password here
|
23
|
+
:host: localhost
|
24
|
+
:server: passenger
|
25
|
+
:shell: bash -l -c
|
data/traquitana.gemspec
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/traquitana/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Eustaquio Rangel"]
|
6
|
+
gem.email = ["eustaquiorangel@gmail.com"]
|
7
|
+
gem.description = %q{Simple tool for deploy Rails apps}
|
8
|
+
gem.summary = %q{Just a simple tool to deploy Rails apps with SSH and some shell scripts}
|
9
|
+
gem.homepage = "http://github.com/taq/traquitana"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "traquitana"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Traquitana::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency("rubyzip", [">= 0"])
|
19
|
+
gem.add_dependency("net-ssh", [">= 0"])
|
20
|
+
gem.add_dependency("net-scp", [">= 0"])
|
21
|
+
end
|
metadata
CHANGED
@@ -1,19 +1,19 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traquitana
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
|
-
- Eustaquio
|
8
|
+
- Eustaquio Rangel
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-08-
|
12
|
+
date: 2012-08-22 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rubyzip
|
16
|
-
requirement: &
|
16
|
+
requirement: &83391740 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *83391740
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: net-ssh
|
27
|
-
requirement: &
|
27
|
+
requirement: &83391480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *83391480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: net-scp
|
38
|
-
requirement: &
|
38
|
+
requirement: &83391240 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,20 +43,77 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *83391240
|
47
47
|
description: Simple tool for deploy Rails apps
|
48
|
-
email:
|
48
|
+
email:
|
49
|
+
- eustaquiorangel@gmail.com
|
49
50
|
executables:
|
50
51
|
- traq
|
51
52
|
extensions: []
|
52
53
|
extra_rdoc_files: []
|
53
54
|
files:
|
55
|
+
- .gitignore
|
56
|
+
- Gemfile
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
54
60
|
- bin/traq
|
55
|
-
- lib/config.rb
|
56
|
-
- lib/deploy.rb
|
57
61
|
- config/default.yml
|
62
|
+
- config/extra.sh
|
63
|
+
- config/nginx.sh
|
58
64
|
- config/passenger.sh
|
59
65
|
- config/proc.sh
|
66
|
+
- config/traq.yml
|
67
|
+
- lib/bar.rb
|
68
|
+
- lib/cleaner.rb
|
69
|
+
- lib/config.rb
|
70
|
+
- lib/deployer.rb
|
71
|
+
- lib/migrator.rb
|
72
|
+
- lib/packager.rb
|
73
|
+
- lib/selector.rb
|
74
|
+
- lib/ssh.rb
|
75
|
+
- lib/traquitana.rb
|
76
|
+
- lib/traquitana/version.rb
|
77
|
+
- spec/bar_spec.rb
|
78
|
+
- spec/cleaner_spec.rb
|
79
|
+
- spec/config/Gemfile
|
80
|
+
- spec/config/Rakefile
|
81
|
+
- spec/config/app/controllers/people_controller.rb
|
82
|
+
- spec/config/app/models/people.rb
|
83
|
+
- spec/config/app/views/people/index.html.erb
|
84
|
+
- spec/config/app/views/people/show.html.erb
|
85
|
+
- spec/config/config.ru
|
86
|
+
- spec/config/config/application.rb
|
87
|
+
- spec/config/config/environment.rb
|
88
|
+
- spec/config/config/environments/production.rb
|
89
|
+
- spec/config/config/initializers/inflections.rb
|
90
|
+
- spec/config/config/initializers/mime_types.rb
|
91
|
+
- spec/config/config/locales/en.yml
|
92
|
+
- spec/config/config/locales/pt-BR.yml
|
93
|
+
- spec/config/config/routes.rb
|
94
|
+
- spec/config/config/traq.yml
|
95
|
+
- spec/config/db/migrate/one.rb
|
96
|
+
- spec/config/db/migrate/two.rb
|
97
|
+
- spec/config/lib/test.rb
|
98
|
+
- spec/config/network_test.txt
|
99
|
+
- spec/config/public/images/one.jpg
|
100
|
+
- spec/config/public/images/themes/dark/dark.jpg
|
101
|
+
- spec/config/public/images/themes/theme.jpg
|
102
|
+
- spec/config/public/images/three.jpg
|
103
|
+
- spec/config/public/images/two.jpg
|
104
|
+
- spec/config/public/images/uploads/avatars/avatar.jpg
|
105
|
+
- spec/config/public/images/uploads/people/person.jpg
|
106
|
+
- spec/config/public/images/uploads/upload.jpg
|
107
|
+
- spec/config/public/javascripts/application.js
|
108
|
+
- spec/config/public/stylesheets/application.css
|
109
|
+
- spec/config_spec.rb
|
110
|
+
- spec/deploy_spec.rb
|
111
|
+
- spec/migrator_spec.rb
|
112
|
+
- spec/network_spec.rb
|
113
|
+
- spec/packager_spec.rb
|
114
|
+
- spec/selector_spec.rb
|
115
|
+
- traq/config.yml
|
116
|
+
- traquitana.gemspec
|
60
117
|
homepage: http://github.com/taq/traquitana
|
61
118
|
licenses: []
|
62
119
|
post_install_message:
|
@@ -80,5 +137,43 @@ rubyforge_project:
|
|
80
137
|
rubygems_version: 1.8.10
|
81
138
|
signing_key:
|
82
139
|
specification_version: 3
|
83
|
-
summary:
|
84
|
-
test_files:
|
140
|
+
summary: Just a simple tool to deploy Rails apps with SSH and some shell scripts
|
141
|
+
test_files:
|
142
|
+
- spec/bar_spec.rb
|
143
|
+
- spec/cleaner_spec.rb
|
144
|
+
- spec/config/Gemfile
|
145
|
+
- spec/config/Rakefile
|
146
|
+
- spec/config/app/controllers/people_controller.rb
|
147
|
+
- spec/config/app/models/people.rb
|
148
|
+
- spec/config/app/views/people/index.html.erb
|
149
|
+
- spec/config/app/views/people/show.html.erb
|
150
|
+
- spec/config/config.ru
|
151
|
+
- spec/config/config/application.rb
|
152
|
+
- spec/config/config/environment.rb
|
153
|
+
- spec/config/config/environments/production.rb
|
154
|
+
- spec/config/config/initializers/inflections.rb
|
155
|
+
- spec/config/config/initializers/mime_types.rb
|
156
|
+
- spec/config/config/locales/en.yml
|
157
|
+
- spec/config/config/locales/pt-BR.yml
|
158
|
+
- spec/config/config/routes.rb
|
159
|
+
- spec/config/config/traq.yml
|
160
|
+
- spec/config/db/migrate/one.rb
|
161
|
+
- spec/config/db/migrate/two.rb
|
162
|
+
- spec/config/lib/test.rb
|
163
|
+
- spec/config/network_test.txt
|
164
|
+
- spec/config/public/images/one.jpg
|
165
|
+
- spec/config/public/images/themes/dark/dark.jpg
|
166
|
+
- spec/config/public/images/themes/theme.jpg
|
167
|
+
- spec/config/public/images/three.jpg
|
168
|
+
- spec/config/public/images/two.jpg
|
169
|
+
- spec/config/public/images/uploads/avatars/avatar.jpg
|
170
|
+
- spec/config/public/images/uploads/people/person.jpg
|
171
|
+
- spec/config/public/images/uploads/upload.jpg
|
172
|
+
- spec/config/public/javascripts/application.js
|
173
|
+
- spec/config/public/stylesheets/application.css
|
174
|
+
- spec/config_spec.rb
|
175
|
+
- spec/deploy_spec.rb
|
176
|
+
- spec/migrator_spec.rb
|
177
|
+
- spec/network_spec.rb
|
178
|
+
- spec/packager_spec.rb
|
179
|
+
- spec/selector_spec.rb
|
data/lib/deploy.rb
DELETED
@@ -1,151 +0,0 @@
|
|
1
|
-
module Traquitana
|
2
|
-
class Deploy
|
3
|
-
TRAQ_VERSION="0.0.10"
|
4
|
-
|
5
|
-
def initialize
|
6
|
-
@config = Traquitana::Config.instance
|
7
|
-
@progress = -1
|
8
|
-
end
|
9
|
-
|
10
|
-
def section_msg(msg)
|
11
|
-
puts "\n#{msg}"
|
12
|
-
puts "#{'-'*msg.size}\n"
|
13
|
-
end
|
14
|
-
|
15
|
-
def setup
|
16
|
-
puts "Running setup"
|
17
|
-
if !File.exist?(@config.dir)
|
18
|
-
Dir.mkdir(@config.dir)
|
19
|
-
end
|
20
|
-
puts "Writing #{@config.config}"
|
21
|
-
File.open(@config.config,"w") do |file|
|
22
|
-
file << "# Default configuration"
|
23
|
-
file << File.read(@config.default)
|
24
|
-
end
|
25
|
-
puts "Setup completed!"
|
26
|
-
puts "You MUST check the configurations on #{@config.config} before deploying!"
|
27
|
-
exit 1
|
28
|
-
end
|
29
|
-
|
30
|
-
def show_bar(name,sent,total)
|
31
|
-
bt, bp = 20, 5
|
32
|
-
return if sent<=0
|
33
|
-
|
34
|
-
prop = sent > 0 ? ((100/(total/sent.to_f))/bp).to_i : 0
|
35
|
-
return if prop<=0
|
36
|
-
|
37
|
-
if prop != @progress
|
38
|
-
bar = Array.new(bt,"-")
|
39
|
-
bar[0...prop] = Array.new(prop,"*")
|
40
|
-
name = File.basename(name).ljust(20)
|
41
|
-
STDOUT.print "Sending #{name} #{(prop*bp).to_s.rjust(3)}% : #{bar.join}\r"
|
42
|
-
STDOUT.flush
|
43
|
-
@progress = prop
|
44
|
-
end
|
45
|
-
if sent==total
|
46
|
-
puts "\n#{name.strip} sent.\n"
|
47
|
-
@progress = -1
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def upload(scp,from,to)
|
52
|
-
puts " "
|
53
|
-
scp.upload!(from,to) do |ch,name,sent,total|
|
54
|
-
show_bar(name,sent,total)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def run
|
59
|
-
if !File.exist?(@config.config)
|
60
|
-
STDERR.puts "No config file (#{@config.config}) found."
|
61
|
-
STDERR.puts "Did you run traq setup?"
|
62
|
-
STDERR.puts "Run it and check the configuration before deploying."
|
63
|
-
exit 1
|
64
|
-
end
|
65
|
-
@config.load
|
66
|
-
@shell = @config.shell ? "#{@config.shell} " : ""
|
67
|
-
|
68
|
-
puts "Running Traquitana version #{TRAQ_VERSION}\n"
|
69
|
-
puts "Connecting to #{@config.host} with #{@config.user}, sending files to #{@config.directory}"
|
70
|
-
section_msg("Checking changed files on the last #{@config.ignore} hour(s)")
|
71
|
-
all_list = []
|
72
|
-
|
73
|
-
for files in @config.list
|
74
|
-
send, ignore = files
|
75
|
-
puts "Will send #{send}"+(ignore ? " and ignore #{ignore}" : "")
|
76
|
-
send_list = Dir.glob(send)
|
77
|
-
next if send_list.size<1
|
78
|
-
if ignore
|
79
|
-
ignore_list = Dir.glob(ignore)
|
80
|
-
end
|
81
|
-
result = ignore_list ? send_list - ignore_list : send_list
|
82
|
-
result = result.select {|item| f = File.new(item); !File.directory?(item) && (Time.now-f.mtime)/3600 <= @config.ignore }
|
83
|
-
all_list.push(*result)
|
84
|
-
end
|
85
|
-
|
86
|
-
if all_list.size < 1
|
87
|
-
puts "\nNo files changed on the last #{@config.ignore} hour(s)."
|
88
|
-
exit 1
|
89
|
-
end
|
90
|
-
|
91
|
-
# current id and files
|
92
|
-
id = Time.now.to_f.to_s.sub(/\./,"")
|
93
|
-
all_list_file = "#{id}.list"
|
94
|
-
all_list_zip = "#{id}.zip"
|
95
|
-
|
96
|
-
# first time running? send database.yml also
|
97
|
-
first_run_file = "traq/.first_run"
|
98
|
-
if Dir.glob(first_run_file).size<1
|
99
|
-
puts "Will send config/database.yml"
|
100
|
-
all_list << "config/database.yml"
|
101
|
-
FileUtils.touch(first_run_file)
|
102
|
-
end
|
103
|
-
|
104
|
-
File.open(all_list_file,"w") {|file| file << all_list.join("\n")}
|
105
|
-
section_msg("File list created")
|
106
|
-
|
107
|
-
section_msg("Creating ZIP file with #{all_list.size} files")
|
108
|
-
File.unlink(all_list_zip) if File.exist?(all_list_zip)
|
109
|
-
Zip::ZipFile.open(all_list_zip,true) do |zipfile|
|
110
|
-
all_list.each do |file|
|
111
|
-
puts "Adding #{file} ..."
|
112
|
-
zipfile.add(file,file)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
puts "ZIP file created."
|
116
|
-
|
117
|
-
section_msg("Sending list, ZIP file and control files to remote host")
|
118
|
-
migrate = all_list.find {|item| item =~ /db\/migrate/}
|
119
|
-
options = @config.password.size>1 ? {:password=>@config.password} : {}
|
120
|
-
|
121
|
-
# check if the traq directory exists
|
122
|
-
Net::SSH.start(@config.host,@config.user,options) do |ssh|
|
123
|
-
ssh.exec!("mkdir -p #{@config.directory}/traq")
|
124
|
-
end
|
125
|
-
|
126
|
-
Net::SCP.start(@config.host,@config.user,options) do |scp|
|
127
|
-
upload(scp,"#{File.dirname(File.expand_path(__FILE__))}/../config/proc.sh","#{@config.directory}/traq/proc.sh")
|
128
|
-
upload(scp,"#{File.dirname(File.expand_path(__FILE__))}/../config/#{@config.server}.sh","#{@config.directory}/traq/server.sh")
|
129
|
-
upload(scp,all_list_file,"#{@config.directory}/traq/#{all_list_file}")
|
130
|
-
upload(scp,all_list_zip ,"#{@config.directory}/traq/#{all_list_zip}")
|
131
|
-
end
|
132
|
-
section_msg("Running processes on the remote server")
|
133
|
-
|
134
|
-
Net::SSH.start(@config.host,@config.user,options) do |ssh|
|
135
|
-
result = ""
|
136
|
-
cmd = "#{@config.directory}/traq/proc.sh #{@config.directory}/traq #{all_list_file.split(File.extname(all_list_file)).first}"
|
137
|
-
cmd = "#{@shell} \"#{cmd}\"" if @shell
|
138
|
-
|
139
|
-
ssh.exec!(cmd) do |channel, stream, data|
|
140
|
-
result << data
|
141
|
-
end
|
142
|
-
puts result
|
143
|
-
end
|
144
|
-
puts "\nDone. Have fun.\n"
|
145
|
-
|
146
|
-
# clean up
|
147
|
-
File.unlink(all_list_file)
|
148
|
-
File.unlink(all_list_zip)
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|