docker-sync 0.4.6 → 0.5.0.pre.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/bin/console +6 -0
- data/lib/docker-sync.rb +2 -1
- data/lib/docker-sync/config/project_config.rb +13 -12
- data/lib/docker-sync/dependencies.rb +39 -0
- data/lib/docker-sync/dependencies/docker.rb +23 -0
- data/lib/docker-sync/dependencies/docker_driver.rb +20 -0
- data/lib/docker-sync/dependencies/fswatch.rb +14 -0
- data/lib/docker-sync/dependencies/package_manager.rb +24 -0
- data/lib/docker-sync/dependencies/package_managers/apt.rb +24 -0
- data/lib/docker-sync/dependencies/package_managers/base.rb +47 -0
- data/lib/docker-sync/dependencies/package_managers/brew.rb +24 -0
- data/lib/docker-sync/dependencies/package_managers/none.rb +23 -0
- data/lib/docker-sync/dependencies/package_managers/pkg.rb +24 -0
- data/lib/docker-sync/dependencies/package_managers/yum.rb +24 -0
- data/lib/docker-sync/dependencies/rsync.rb +14 -0
- data/lib/docker-sync/dependencies/unison.rb +15 -0
- data/lib/docker-sync/dependencies/unox.rb +40 -0
- data/lib/docker-sync/environment.rb +19 -0
- data/lib/docker-sync/execution.rb +11 -35
- data/lib/docker-sync/sync_manager.rb +10 -3
- data/lib/docker-sync/sync_process.rb +16 -18
- data/lib/docker-sync/sync_strategy/native.rb +3 -4
- data/lib/docker-sync/sync_strategy/native_osx.rb +11 -11
- data/lib/docker-sync/sync_strategy/rsync.rb +15 -7
- data/lib/docker-sync/sync_strategy/unison.rb +13 -12
- data/lib/docker-sync/update_check.rb +5 -0
- data/lib/docker-sync/upgrade_check.rb +2 -1
- data/lib/docker-sync/watch_strategy/dummy.rb +1 -1
- data/lib/docker-sync/watch_strategy/fswatch.rb +4 -5
- data/lib/docker-sync/watch_strategy/remotelogs.rb +3 -3
- data/lib/docker-sync/watch_strategy/unison.rb +2 -2
- data/tasks/daemon/daemon.thor +0 -1
- data/tasks/stack/stack.thor +8 -9
- data/tasks/sync/sync.thor +16 -19
- metadata +21 -9
- data/lib/docker-sync/preconditions/preconditions_linux.rb +0 -51
- data/lib/docker-sync/preconditions/preconditions_osx.rb +0 -174
- data/lib/docker-sync/preconditions/strategy.rb +0 -65
@@ -11,6 +11,7 @@ class UpgradeChecker
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def run
|
14
|
+
return if ENV['DOCKER_SYNC_SKIP_UPGRADE']
|
14
15
|
unless should_run
|
15
16
|
return
|
16
17
|
end
|
@@ -50,6 +51,7 @@ class UpgradeChecker
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def check_and_warn
|
54
|
+
return if ENV['DOCKER_SYNC_SKIP_UPGRADE']
|
53
55
|
# this is the upgrade hook for the unison-unox introduction / rename of unison
|
54
56
|
if Gem::Version.new(last_upgraded_version) < Gem::Version.new('0.1.0')
|
55
57
|
Thor::Shell::Basic.new.say_status 'warning', 'Please be aware that with the strategy "unison" is now called unison-onesided and you might need to migrate. See https://github.com/EugenMayer/docker-sync/wiki/Migration-Guide for more informations', :red
|
@@ -75,7 +77,6 @@ class UpgradeChecker
|
|
75
77
|
system cmd1
|
76
78
|
else
|
77
79
|
raise('Please reinstall docker-sync yourself')
|
78
|
-
exit 1
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'thor/shell'
|
2
2
|
require 'docker-sync/execution'
|
3
|
-
require 'docker-sync/preconditions/strategy'
|
4
3
|
require 'pathname'
|
5
4
|
|
6
|
-
module
|
5
|
+
module DockerSync
|
7
6
|
module WatchStrategy
|
8
7
|
class Fswatch
|
9
8
|
include Thor::Shell
|
@@ -19,8 +18,8 @@ module Docker_Sync
|
|
19
18
|
@events_to_watch = %w(AttributeModified Created Link MovedFrom MovedTo Renamed Removed Updated)
|
20
19
|
|
21
20
|
begin
|
22
|
-
|
23
|
-
rescue
|
21
|
+
Dependencies::Fswatch.ensure!
|
22
|
+
rescue StandardError => e
|
24
23
|
say_status 'error', e.message, :red
|
25
24
|
exit 1
|
26
25
|
end
|
@@ -43,7 +42,7 @@ module Docker_Sync
|
|
43
42
|
say_status 'command', cmd, :white if @options['verbose']
|
44
43
|
|
45
44
|
# run a thread here, since it is blocking
|
46
|
-
@watch_thread =
|
45
|
+
@watch_thread = thread_exec(cmd, "Sync #{@sync_name}", :blue)
|
47
46
|
end
|
48
47
|
|
49
48
|
def watch_options
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'thor/shell'
|
2
2
|
require 'docker-sync/execution'
|
3
3
|
|
4
|
-
module
|
4
|
+
module DockerSync
|
5
5
|
module WatchStrategy
|
6
6
|
class Remote_logs
|
7
7
|
include Thor::Shell
|
@@ -17,13 +17,13 @@ module Docker_Sync
|
|
17
17
|
@sync_name = sync_name
|
18
18
|
@watch_fork = nil
|
19
19
|
@watch_thread = nil
|
20
|
-
@unison =
|
20
|
+
@unison = DockerSync::SyncStrategy::NativeOsx.new(@sync_name, @options)
|
21
21
|
end
|
22
22
|
|
23
23
|
def run
|
24
24
|
say_status 'success', "Showing unison logs from your sync container: #{@unison.get_container_name}", :green
|
25
25
|
cmd = "docker exec #{@unison.get_container_name} tail -F /tmp/unison.log"
|
26
|
-
@watch_thread =
|
26
|
+
@watch_thread = thread_exec(cmd, 'Sync Log:')
|
27
27
|
end
|
28
28
|
|
29
29
|
def stop
|
@@ -2,7 +2,7 @@ require 'thor/shell'
|
|
2
2
|
require 'docker-sync/execution'
|
3
3
|
require 'docker-sync/sync_strategy/unison'
|
4
4
|
|
5
|
-
module
|
5
|
+
module DockerSync
|
6
6
|
module WatchStrategy
|
7
7
|
class Unison
|
8
8
|
include Execution
|
@@ -19,7 +19,7 @@ module Docker_Sync
|
|
19
19
|
# unison sync and watch
|
20
20
|
# basically unison watch is the command with the additionnal -repeat watch option
|
21
21
|
# note: this doesn't run a sync
|
22
|
-
@unison =
|
22
|
+
@unison = DockerSync::SyncStrategy::Unison.new(@sync_name, @options)
|
23
23
|
end
|
24
24
|
|
25
25
|
def run
|
data/tasks/daemon/daemon.thor
CHANGED
data/tasks/stack/stack.thor
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'docker-sync'
|
2
2
|
require 'docker-sync/sync_manager'
|
3
|
-
require 'docker-sync/preconditions/strategy'
|
4
3
|
require 'docker-sync/update_check'
|
5
4
|
require 'docker-sync/upgrade_check'
|
6
5
|
require 'docker/compose'
|
@@ -35,15 +34,15 @@ class Stack < Thor
|
|
35
34
|
|
36
35
|
begin
|
37
36
|
config = DockerSync::ProjectConfig.new(config_path: options[:config])
|
38
|
-
DockerSync::
|
39
|
-
rescue
|
37
|
+
DockerSync::Dependencies.ensure_all!(config)
|
38
|
+
rescue StandardError => e
|
40
39
|
say_status 'error', e.message, :red
|
41
40
|
exit(1)
|
42
41
|
end
|
43
42
|
|
44
|
-
say_status 'note:', 'You can also run docker-sync in the background with docker-sync
|
43
|
+
say_status 'note:', 'You can also run docker-sync in the background with docker-sync start'
|
45
44
|
|
46
|
-
@sync_manager =
|
45
|
+
@sync_manager = DockerSync::SyncManager.new(config: config)
|
47
46
|
@sync_manager.run(options[:sync_name])
|
48
47
|
global_options = @sync_manager.global_options
|
49
48
|
@compose_manager = ComposeManager.new(global_options)
|
@@ -60,7 +59,7 @@ class Stack < Thor
|
|
60
59
|
|
61
60
|
@sync_manager.stop
|
62
61
|
@compose_manager.stop
|
63
|
-
rescue
|
62
|
+
rescue StandardError => e
|
64
63
|
puts "EXCEPTION: #{e.inspect}"
|
65
64
|
puts "MESSAGE: #{e.message}"
|
66
65
|
end
|
@@ -76,13 +75,13 @@ class Stack < Thor
|
|
76
75
|
|
77
76
|
begin
|
78
77
|
config = DockerSync::ProjectConfig.new(config_path: options[:config])
|
79
|
-
DockerSync::
|
80
|
-
rescue
|
78
|
+
DockerSync::Dependencies.ensure_all!(config)
|
79
|
+
rescue StandardError => e
|
81
80
|
say_status 'error', e.message, :red
|
82
81
|
exit(1)
|
83
82
|
end
|
84
83
|
|
85
|
-
@sync_manager =
|
84
|
+
@sync_manager = DockerSync::SyncManager.new(config: config)
|
86
85
|
global_options = @sync_manager.global_options
|
87
86
|
# shutdown compose first
|
88
87
|
@compose_manager = ComposeManager.new(global_options)
|
data/tasks/sync/sync.thor
CHANGED
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'docker-sync'
|
2
2
|
require 'docker-sync/sync_manager'
|
3
|
-
require 'docker-sync/preconditions/strategy'
|
4
3
|
require 'docker-sync/update_check'
|
5
4
|
require 'docker-sync/upgrade_check'
|
6
5
|
require 'daemons'
|
@@ -34,7 +33,7 @@ class Sync < Thor
|
|
34
33
|
UpgradeChecker.new.run
|
35
34
|
|
36
35
|
config = config_preconditions
|
37
|
-
@sync_manager =
|
36
|
+
@sync_manager = DockerSync::SyncManager.new(config: config)
|
38
37
|
|
39
38
|
start_dir = Dir.pwd # Set start_dir variable to be equal to pre-daemonized folder, since daemonizing will change dir to '/'
|
40
39
|
|
@@ -61,7 +60,7 @@ class Sync < Thor
|
|
61
60
|
print_version if options[:version]
|
62
61
|
|
63
62
|
config = config_preconditions
|
64
|
-
sync_manager =
|
63
|
+
sync_manager = DockerSync::SyncManager.new(config: config)
|
65
64
|
sync_manager.stop
|
66
65
|
pid_file_path="#{options['dir']}/#{options['app_name']}.pid"
|
67
66
|
if File.exist?(pid_file_path)
|
@@ -86,7 +85,7 @@ class Sync < Thor
|
|
86
85
|
|
87
86
|
config = config_preconditions
|
88
87
|
|
89
|
-
@sync_manager =
|
88
|
+
@sync_manager = DockerSync::SyncManager.new(config: config)
|
90
89
|
@sync_manager.sync(options[:sync_name])
|
91
90
|
end
|
92
91
|
|
@@ -107,7 +106,7 @@ class Sync < Thor
|
|
107
106
|
# Remove the .docker-sync directory
|
108
107
|
FileUtils.rm_r dir if File.directory?(dir)
|
109
108
|
|
110
|
-
@sync_manager =
|
109
|
+
@sync_manager = DockerSync::SyncManager.new(config: config)
|
111
110
|
@sync_manager.clean(options[:sync_name])
|
112
111
|
say_status 'success', 'Finished cleanup. Removed stopped, removed sync container and removed their volumes', :green
|
113
112
|
end
|
@@ -129,27 +128,25 @@ class Sync < Thor
|
|
129
128
|
def list
|
130
129
|
print_version if options[:version]
|
131
130
|
|
132
|
-
|
131
|
+
project_config = config_preconditions
|
133
132
|
|
134
|
-
say_status 'ok',"Found configuration at #{
|
135
|
-
@sync_manager =
|
136
|
-
@sync_manager.get_sync_points.each do |name,
|
137
|
-
say_status name, "On address #{
|
138
|
-
puts "\n---------------[#{name}] #{
|
139
|
-
print_table(
|
133
|
+
say_status 'ok',"Found configuration at #{project_config.config_path}"
|
134
|
+
@sync_manager = DockerSync::SyncManager.new(config: project_config)
|
135
|
+
@sync_manager.get_sync_points.each do |name, sync_config|
|
136
|
+
say_status name, "On address #{sync_config['sync_host_ip']}:#{sync_config['sync_host_port']}",:white unless options['verbose']
|
137
|
+
puts "\n---------------[#{name}] #{sync_config['sync_host_ip']}:#{sync_config['sync_host_port']} ---------------\n" if options['verbose']
|
138
|
+
print_table(sync_config) if options['verbose']
|
140
139
|
end
|
141
140
|
end
|
142
141
|
|
143
142
|
no_tasks do
|
144
143
|
def config_preconditions # Moved shared preconditions block into separate method to have less/cleaner code
|
145
|
-
|
146
|
-
DockerSync::
|
147
|
-
DockerSync::Preconditions::Strategy.instance.check_all_preconditions(config)
|
148
|
-
end
|
149
|
-
rescue Exception => e
|
150
|
-
say_status 'error', e.message, :red
|
151
|
-
exit 1
|
144
|
+
DockerSync::ProjectConfig.new(config_path: options[:config]).tap do |config|
|
145
|
+
DockerSync::Dependencies.ensure_all!(config)
|
152
146
|
end
|
147
|
+
rescue StandardError => e
|
148
|
+
say_status 'error', e.message, :red
|
149
|
+
exit 1
|
153
150
|
end
|
154
151
|
|
155
152
|
def daemonize
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: docker-sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0.pre.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eugen Mayer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -174,10 +174,22 @@ files:
|
|
174
174
|
- lib/docker-sync/config/config_serializer.rb
|
175
175
|
- lib/docker-sync/config/global_config.rb
|
176
176
|
- lib/docker-sync/config/project_config.rb
|
177
|
+
- lib/docker-sync/dependencies.rb
|
178
|
+
- lib/docker-sync/dependencies/docker.rb
|
179
|
+
- lib/docker-sync/dependencies/docker_driver.rb
|
180
|
+
- lib/docker-sync/dependencies/fswatch.rb
|
181
|
+
- lib/docker-sync/dependencies/package_manager.rb
|
182
|
+
- lib/docker-sync/dependencies/package_managers/apt.rb
|
183
|
+
- lib/docker-sync/dependencies/package_managers/base.rb
|
184
|
+
- lib/docker-sync/dependencies/package_managers/brew.rb
|
185
|
+
- lib/docker-sync/dependencies/package_managers/none.rb
|
186
|
+
- lib/docker-sync/dependencies/package_managers/pkg.rb
|
187
|
+
- lib/docker-sync/dependencies/package_managers/yum.rb
|
188
|
+
- lib/docker-sync/dependencies/rsync.rb
|
189
|
+
- lib/docker-sync/dependencies/unison.rb
|
190
|
+
- lib/docker-sync/dependencies/unox.rb
|
191
|
+
- lib/docker-sync/environment.rb
|
177
192
|
- lib/docker-sync/execution.rb
|
178
|
-
- lib/docker-sync/preconditions/preconditions_linux.rb
|
179
|
-
- lib/docker-sync/preconditions/preconditions_osx.rb
|
180
|
-
- lib/docker-sync/preconditions/strategy.rb
|
181
193
|
- lib/docker-sync/sync_manager.rb
|
182
194
|
- lib/docker-sync/sync_process.rb
|
183
195
|
- lib/docker-sync/sync_strategy/native.rb
|
@@ -195,7 +207,7 @@ files:
|
|
195
207
|
- tasks/sync/sync.thor
|
196
208
|
homepage: https://github.com/EugenMayer/docker_sync
|
197
209
|
licenses:
|
198
|
-
- GPL
|
210
|
+
- GPL-3.0
|
199
211
|
metadata: {}
|
200
212
|
post_install_message:
|
201
213
|
rdoc_options: []
|
@@ -208,12 +220,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
220
|
version: '2.0'
|
209
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
210
222
|
requirements:
|
211
|
-
- - "
|
223
|
+
- - ">"
|
212
224
|
- !ruby/object:Gem::Version
|
213
|
-
version:
|
225
|
+
version: 1.3.1
|
214
226
|
requirements: []
|
215
227
|
rubyforge_project:
|
216
|
-
rubygems_version: 2.
|
228
|
+
rubygems_version: 2.5.2
|
217
229
|
signing_key:
|
218
230
|
specification_version: 4
|
219
231
|
summary: Docker Sync - Fast and efficient way to sync code to docker-containers
|
@@ -1,51 +0,0 @@
|
|
1
|
-
module DockerSync
|
2
|
-
module Preconditions
|
3
|
-
class Linux
|
4
|
-
def check_all_preconditions(config)
|
5
|
-
return unless should_run_precondition?
|
6
|
-
|
7
|
-
docker_available
|
8
|
-
docker_running
|
9
|
-
|
10
|
-
if config.unison_required?
|
11
|
-
unison_available
|
12
|
-
end
|
13
|
-
|
14
|
-
if config.rsync_required?
|
15
|
-
rsync_available
|
16
|
-
fswatch_available
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def docker_available
|
21
|
-
end
|
22
|
-
|
23
|
-
def docker_running
|
24
|
-
end
|
25
|
-
|
26
|
-
def fswatch_available
|
27
|
-
end
|
28
|
-
|
29
|
-
def rsync_available
|
30
|
-
end
|
31
|
-
|
32
|
-
def unison_available
|
33
|
-
end
|
34
|
-
|
35
|
-
def is_driver_docker_for_mac?
|
36
|
-
return false
|
37
|
-
end
|
38
|
-
|
39
|
-
def is_driver_docker_toolbox?
|
40
|
-
return false
|
41
|
-
end
|
42
|
-
private
|
43
|
-
|
44
|
-
def should_run_precondition?(silent: false)
|
45
|
-
true
|
46
|
-
end
|
47
|
-
|
48
|
-
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,174 +0,0 @@
|
|
1
|
-
require 'mkmf'
|
2
|
-
module DockerSync
|
3
|
-
module Preconditions
|
4
|
-
class Osx
|
5
|
-
def check_all_preconditions(config)
|
6
|
-
return unless should_run_precondition?
|
7
|
-
|
8
|
-
docker_available
|
9
|
-
docker_running
|
10
|
-
|
11
|
-
if config.unison_required?
|
12
|
-
unison_available
|
13
|
-
end
|
14
|
-
|
15
|
-
if config.rsync_required?
|
16
|
-
rsync_available
|
17
|
-
fswatch_available
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def docker_available
|
22
|
-
if (find_executable0 'docker').nil?
|
23
|
-
raise('Could not find docker binary in path. Please install it, e.g. using "brew install docker" or install docker-for-mac')
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def docker_running
|
28
|
-
`docker ps`
|
29
|
-
if $?.exitstatus > 0
|
30
|
-
raise('No docker daemon seems to be running. Did you start your docker-for-mac / docker-machine?')
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def rsync_available
|
35
|
-
if should_run_precondition?
|
36
|
-
if (find_executable0 'rsync').nil?
|
37
|
-
raise('Could not find rsync binary in path. Please install it, e.g. using "brew install rsync"')
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def unison_available
|
43
|
-
if should_run_precondition?
|
44
|
-
if (find_executable0 'unison').nil?
|
45
|
-
cmd1 = 'brew install unison'
|
46
|
-
|
47
|
-
Thor::Shell::Basic.new.say_status 'warning', 'Could not find unison binary in $PATH. Trying to install now', :red
|
48
|
-
Thor::Shell::Basic.new.say_status 'command', cmd1, :white
|
49
|
-
if Thor::Shell::Basic.new.yes?('I will install unison using brew for you? (y/N)')
|
50
|
-
system cmd1
|
51
|
-
else
|
52
|
-
raise('Please install it yourself using: brew install unison')
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
unox_available
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
def fswatch_available
|
61
|
-
if should_run_precondition?
|
62
|
-
if (find_executable0 'fswatch').nil?
|
63
|
-
cmd1 = 'brew install fswatch'
|
64
|
-
|
65
|
-
Thor::Shell::Basic.new.say_status 'warning', 'No fswatch available. Install it by "brew install fswatch Trying to install now', :red
|
66
|
-
if Thor::Shell::Basic.new.yes?('I will install fswatch using brew for you? (y/N)')
|
67
|
-
system cmd1
|
68
|
-
else
|
69
|
-
raise('Please install it yourself using: brew install fswatch')
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
|
76
|
-
def is_driver_docker_for_mac?
|
77
|
-
`docker info | grep 'Docker Root Dir: /var/lib/docker' && docker info | grep 'Operating System: Alpine Linux'`
|
78
|
-
$?.success?
|
79
|
-
end
|
80
|
-
|
81
|
-
def is_driver_docker_toolbox?
|
82
|
-
return false unless find_executable0('docker-machine')
|
83
|
-
`docker info | grep 'Operating System: Boot2Docker'`
|
84
|
-
$?.success?
|
85
|
-
end
|
86
|
-
|
87
|
-
private
|
88
|
-
|
89
|
-
def should_run_precondition?(silent = false)
|
90
|
-
unless has_brew?
|
91
|
-
Thor::Shell::Basic.new.say_status 'info', 'Not running any precondition checks since you have no brew and that is unsupported. Is all up to you know.', :white unless silent
|
92
|
-
return false
|
93
|
-
end
|
94
|
-
return true
|
95
|
-
end
|
96
|
-
|
97
|
-
def has_brew?
|
98
|
-
return find_executable0 'brew'
|
99
|
-
end
|
100
|
-
|
101
|
-
|
102
|
-
def unox_available
|
103
|
-
if should_run_precondition?
|
104
|
-
if defined? Bundler
|
105
|
-
Bundler.with_clean_env { `brew list unox` }
|
106
|
-
else
|
107
|
-
`brew list unox`
|
108
|
-
end
|
109
|
-
|
110
|
-
unless $?.success?
|
111
|
-
# unox installed, but not using brew, we do not allow that anymore
|
112
|
-
if File.exist?('/usr/local/bin/unison-fsmonitor')
|
113
|
-
Thor::Shell::Basic.new.say_status 'error', 'You installed unison-fsmonitor (unox) not using brew-method - the old legacy way. We need to fix that.', :red
|
114
|
-
|
115
|
-
uninstall_cmd='sudo rm /usr/local/bin/unison-fsmonitor'
|
116
|
-
Thor::Shell::Basic.new.say_status 'command', uninstall_cmd, :white
|
117
|
-
if Thor::Shell::Basic.new.yes?('Should i uninstall the legacy /usr/local/bin/unison-fsmonitor for you ? (y/N)')
|
118
|
-
system uninstall_cmd
|
119
|
-
else
|
120
|
-
Thor::Shell::Basic.new.say_status 'error', 'Uninstall /usr/local/bin/unison-fsmonitor manually please', :white
|
121
|
-
exit 1
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
cmd1 = 'brew tap eugenmayer/dockersync && brew install eugenmayer/dockersync/unox'
|
126
|
-
Thor::Shell::Basic.new.say_status 'warning', 'Could not find unison-fsmonitor (unox) binary in $PATH. Trying to install now', :red
|
127
|
-
Thor::Shell::Basic.new.say_status 'command', cmd1, :white
|
128
|
-
if Thor::Shell::Basic.new.yes?('I will install unox through brew for you? (y/N)')
|
129
|
-
system cmd1
|
130
|
-
else
|
131
|
-
raise("Please install it yourself using: #{cmd1}")
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
135
|
-
end
|
136
|
-
|
137
|
-
def install_pip(package, test = nil)
|
138
|
-
test ? `python -c 'import #{test}'` : `python -c 'import #{package}'`
|
139
|
-
|
140
|
-
unless $?.success?
|
141
|
-
Thor::Shell::Basic.new.say_status 'warning', "Could not find #{package}. Will try to install it using pip", :red
|
142
|
-
if find_executable0('python') == '/usr/bin/python'
|
143
|
-
Thor::Shell::Basic.new.say_status 'ok', 'You seem to use the system python, we will need sudo below'
|
144
|
-
sudo = true
|
145
|
-
cmd2 = "sudo easy_install pip && sudo pip install #{package}"
|
146
|
-
else
|
147
|
-
Thor::Shell::Basic.new.say_status 'ok', 'You seem to have a custom python, using non-sudo commands'
|
148
|
-
sudo = false
|
149
|
-
cmd2 = "easy_install pip && pip install #{package}"
|
150
|
-
end
|
151
|
-
if sudo
|
152
|
-
question = "I will ask you for you root password to install #{package} by running (This will ask for sudo, since we use the system python)"
|
153
|
-
else
|
154
|
-
question = "I will now install #{package} for you by running"
|
155
|
-
end
|
156
|
-
|
157
|
-
Thor::Shell::Basic.new.say_status 'info', "#{question}: `#{cmd2}\n\n"
|
158
|
-
if Thor::Shell::Basic.new.yes?('Shall I continue? (y/N)')
|
159
|
-
system cmd2
|
160
|
-
if $?.exitstatus > 0
|
161
|
-
raise("Failed to install #{package}, please file an issue with the output of the error")
|
162
|
-
end
|
163
|
-
test ? `python -c 'import #{test}'` : `python -c 'import #{package}'`
|
164
|
-
unless $?.success?
|
165
|
-
raise("Somehow I could not successfully install #{package} even though I tried. Please report this issue.")
|
166
|
-
end
|
167
|
-
else
|
168
|
-
raise("Please install #{package} manually, see https://github.com/EugenMayer/docker-sync/wiki/1.-Installation")
|
169
|
-
end
|
170
|
-
end
|
171
|
-
end
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|