picobox 0.1.7 → 0.2.0
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.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/README.md +1 -1
- data/lib/picobox.rb +9 -4
- data/lib/picobox/box.rb +2 -2
- data/lib/picobox/boxes/manifest.rb +1 -1
- data/lib/picobox/cli.rb +62 -10
- data/lib/picobox/commands/add_box.rb +6 -2
- data/lib/picobox/commands/add_service.rb +6 -2
- data/lib/picobox/commands/build_service.rb +8 -1
- data/lib/picobox/commands/download_docker.rb +23 -5
- data/lib/picobox/commands/finish_install.rb +6 -0
- data/lib/picobox/commands/finish_uninstall.rb +5 -0
- data/lib/picobox/commands/get_root_permission.rb +14 -0
- data/lib/picobox/commands/initialize_project.rb +6 -4
- data/lib/picobox/commands/install_docker.rb +31 -5
- data/lib/picobox/commands/list_boxes.rb +4 -4
- data/lib/picobox/commands/list_services.rb +4 -4
- data/lib/picobox/commands/reload_shell.rb +15 -0
- data/lib/picobox/commands/remove_service.rb +6 -2
- data/lib/picobox/commands/remove_setup_shell.rb +6 -4
- data/lib/picobox/commands/restart.rb +8 -7
- data/lib/picobox/commands/setup_shell.rb +7 -4
- data/lib/picobox/commands/{open_shell.rb → ssh_instance.rb} +8 -4
- data/lib/picobox/commands/start.rb +6 -5
- data/lib/picobox/commands/start_install.rb +5 -0
- data/lib/picobox/commands/start_uninstall.rb +5 -4
- data/lib/picobox/commands/stop.rb +6 -5
- data/lib/picobox/constants.rb +14 -1
- data/lib/picobox/errors/picobox_error.rb +1 -0
- data/lib/picobox/handlers/stdout_handler.rb +40 -16
- data/lib/picobox/os/abstract.rb +4 -4
- data/lib/picobox/os/current_os.rb +1 -0
- data/lib/picobox/os/distro.rb +32 -0
- data/lib/picobox/os/linux.rb +14 -0
- data/lib/picobox/project.rb +2 -2
- data/lib/picobox/service.rb +4 -4
- data/lib/picobox/services/manifest.rb +1 -1
- data/lib/picobox/shell/dot_bashrc.rb +9 -0
- data/lib/picobox/shell/dot_profile.rb +1 -34
- data/lib/picobox/shell/dot_zshrc.rb +1 -34
- data/lib/picobox/shell/startup_script.rb +40 -1
- data/lib/picobox/system.rb +13 -8
- data/lib/picobox/utils/output.rb +5 -0
- data/lib/picobox/utils/spinner.rb +27 -0
- data/lib/picobox/utils/visitor_by_os.rb +6 -3
- data/picobox.gemspec +4 -2
- metadata +42 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 649bcb114c8fd7298d2791313377d7700853d080
|
4
|
+
data.tar.gz: f897fc645ff84b0377012c11bb86eece25e04d68
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b215666290df4a457c543a9dfc4bc8efa8db2392669ca1953109dbeba0b257a0a36b1124ca13e35e67a210337bbd71ce1805c6412952cf48af41c21eed7cf9a
|
7
|
+
data.tar.gz: 87a78effe3224a45a9a4eb968090ae95cfe379dd0a602e16570545ce21b5e9c1d592ae71683a6e7c5889b0d4511e02bf80a5024c98c1b330f270c29f3013d442
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -123,7 +123,7 @@ $ bundle exec byebug -R localhost:8989
|
|
123
123
|
- [ ] Uninstall should stop and remove all instances that are running
|
124
124
|
- [ ] Block most commands if picobox not installed
|
125
125
|
- [ ] Some services should install thier own volumes
|
126
|
-
- [ ] Box update
|
126
|
+
- [ ] Box update function
|
127
127
|
|
128
128
|
**http://blog.cloud66.com/using-ssh-private-keys-securely-in-docker-build/
|
129
129
|
|
data/lib/picobox.rb
CHANGED
@@ -6,12 +6,15 @@ require 'uri'
|
|
6
6
|
require 'tty-file'
|
7
7
|
require 'tty-command'
|
8
8
|
require 'tty-platform'
|
9
|
+
require 'tty-which'
|
10
|
+
require 'tty-spinner'
|
9
11
|
require 'ostruct'
|
10
12
|
require 'yaml'
|
11
13
|
require 'inifile'
|
12
14
|
require 'pathname'
|
13
15
|
|
14
16
|
require 'picobox/utils/progress_bar'
|
17
|
+
require 'picobox/utils/spinner'
|
15
18
|
require 'picobox/utils/project'
|
16
19
|
require 'picobox/utils/visitable'
|
17
20
|
require 'picobox/utils/domain_event_publisher'
|
@@ -43,7 +46,9 @@ require 'picobox/commands/remove_service'
|
|
43
46
|
require 'picobox/commands/start'
|
44
47
|
require 'picobox/commands/stop'
|
45
48
|
require 'picobox/commands/restart'
|
46
|
-
require 'picobox/commands/
|
49
|
+
require 'picobox/commands/ssh_instance'
|
50
|
+
require 'picobox/commands/reload_shell'
|
51
|
+
require 'picobox/commands/get_root_permission'
|
47
52
|
|
48
53
|
require 'picobox/boxes/manifest'
|
49
54
|
require 'picobox/boxes/unpacker'
|
@@ -56,10 +61,12 @@ require 'picobox/os/darwin'
|
|
56
61
|
require 'picobox/os/linux'
|
57
62
|
require 'picobox/os/unsupported_os'
|
58
63
|
require 'picobox/os/current_os'
|
64
|
+
require 'picobox/os/distro'
|
59
65
|
|
60
66
|
require 'picobox/shell/startup_script'
|
61
67
|
require 'picobox/shell/dot_profile'
|
62
68
|
require 'picobox/shell/dot_zshrc'
|
69
|
+
require 'picobox/shell/dot_bashrc'
|
63
70
|
|
64
71
|
require 'picobox/constants'
|
65
72
|
require 'picobox/cli'
|
@@ -73,7 +80,5 @@ Wisper.subscribe(
|
|
73
80
|
scope: Picobox::Utils::DomainEventPublisher
|
74
81
|
)
|
75
82
|
|
76
|
-
|
77
|
-
$VERBOSE=nil
|
78
|
-
|
83
|
+
Picobox.set_verbosity(false)
|
79
84
|
|
data/lib/picobox/box.rb
CHANGED
@@ -22,14 +22,14 @@ module Picobox
|
|
22
22
|
rescue Errors::ProjectNotInitialized
|
23
23
|
display_project_not_initialized
|
24
24
|
exit 1
|
25
|
-
rescue
|
25
|
+
rescue StandardError => e
|
26
26
|
display_info(e, :red)
|
27
27
|
exit 1
|
28
28
|
end
|
29
29
|
|
30
30
|
def list()
|
31
31
|
accept(Commands::ListBoxes.new)
|
32
|
-
rescue
|
32
|
+
rescue StandardError => e
|
33
33
|
display_info(e, :red)
|
34
34
|
exit 1
|
35
35
|
end
|
data/lib/picobox/cli.rb
CHANGED
@@ -4,7 +4,11 @@ module Picobox
|
|
4
4
|
long_desc <<-LONGDESC
|
5
5
|
LONGDESC
|
6
6
|
def build(service = nil)
|
7
|
+
Picobox.set_verbosity options[:verbose]
|
8
|
+
|
7
9
|
Service.new(Os::CurrentOs.get).build service
|
10
|
+
rescue SignalException
|
11
|
+
exit 1
|
8
12
|
end
|
9
13
|
|
10
14
|
|
@@ -12,7 +16,11 @@ module Picobox
|
|
12
16
|
long_desc <<-LONGDESC
|
13
17
|
LONGDESC
|
14
18
|
def add(*services)
|
19
|
+
Picobox.set_verbosity options[:verbose]
|
20
|
+
|
15
21
|
Service.new(Os::CurrentOs.get).add services
|
22
|
+
rescue SignalException
|
23
|
+
exit 1
|
16
24
|
end
|
17
25
|
|
18
26
|
|
@@ -20,7 +28,11 @@ module Picobox
|
|
20
28
|
long_desc <<-LONGDESC
|
21
29
|
LONGDESC
|
22
30
|
def remove(service)
|
31
|
+
Picobox.set_verbosity options[:verbose]
|
32
|
+
|
23
33
|
Service.new(Os::CurrentOs.get).remove service
|
34
|
+
rescue SignalException
|
35
|
+
exit 1
|
24
36
|
end
|
25
37
|
|
26
38
|
|
@@ -29,6 +41,8 @@ module Picobox
|
|
29
41
|
LONGDESC
|
30
42
|
def list()
|
31
43
|
Service.new(Os::CurrentOs.get).list
|
44
|
+
rescue SignalException
|
45
|
+
exit 1
|
32
46
|
end
|
33
47
|
end
|
34
48
|
|
@@ -38,17 +52,19 @@ module Picobox
|
|
38
52
|
LONGDESC
|
39
53
|
method_option :port, default: 3000
|
40
54
|
def add(entry)
|
41
|
-
puts "
|
55
|
+
puts "coming soon"
|
42
56
|
end
|
43
57
|
end
|
44
58
|
|
45
59
|
class CLI < Thor
|
46
60
|
include Utils::Output
|
47
61
|
|
48
|
-
desc '
|
49
|
-
|
50
|
-
|
51
|
-
|
62
|
+
class_option :verbose, desc: 'Verbose debugging output', type: :boolean
|
63
|
+
|
64
|
+
#desc 'dns SUBCOMMAND', 'do things with the DNS'
|
65
|
+
#long_desc <<-LONGDESC
|
66
|
+
#LONGDESC
|
67
|
+
#subcommand 'dns', Picobox::DnsSubCommands
|
52
68
|
|
53
69
|
|
54
70
|
desc 'service SUBCOMMAND', 'do things with the SERVICES'
|
@@ -60,6 +76,8 @@ module Picobox
|
|
60
76
|
desc 'version', 'displays current version'
|
61
77
|
def version
|
62
78
|
say Picobox::VERSION
|
79
|
+
rescue SignalException
|
80
|
+
exit 1
|
63
81
|
end
|
64
82
|
|
65
83
|
|
@@ -67,8 +85,11 @@ module Picobox
|
|
67
85
|
long_desc <<-LONGDESC
|
68
86
|
LONGDESC
|
69
87
|
def install
|
88
|
+
Picobox.set_verbosity options[:verbose]
|
89
|
+
|
70
90
|
System.new(Os::CurrentOs.get).install
|
71
|
-
|
91
|
+
rescue SignalException
|
92
|
+
exit 1
|
72
93
|
end
|
73
94
|
|
74
95
|
|
@@ -76,8 +97,11 @@ module Picobox
|
|
76
97
|
long_desc <<-LONGDESC
|
77
98
|
LONGDESC
|
78
99
|
def update
|
100
|
+
Picobox.set_verbosity options[:verbose]
|
101
|
+
|
79
102
|
System.new(Os::CurrentOs.get).install
|
80
|
-
|
103
|
+
rescue SignalException
|
104
|
+
exit 1
|
81
105
|
end
|
82
106
|
|
83
107
|
|
@@ -85,7 +109,11 @@ module Picobox
|
|
85
109
|
long_desc <<-LONGDESC
|
86
110
|
LONGDESC
|
87
111
|
def uninstall
|
112
|
+
Picobox.set_verbosity options[:verbose]
|
113
|
+
|
88
114
|
System.new(Os::CurrentOs.get).uninstall
|
115
|
+
rescue SignalException
|
116
|
+
exit 1
|
89
117
|
end
|
90
118
|
|
91
119
|
|
@@ -93,12 +121,16 @@ module Picobox
|
|
93
121
|
long_desc <<-LONGDESC
|
94
122
|
LONGDESC
|
95
123
|
def init(box)
|
124
|
+
Picobox.set_verbosity options[:verbose]
|
125
|
+
|
96
126
|
os = Os::CurrentOs.get
|
97
127
|
|
98
128
|
Project.new(os).init
|
99
129
|
Box.new(os).install box
|
100
130
|
Service.new(os).build
|
101
131
|
System.new(os).start
|
132
|
+
rescue SignalException
|
133
|
+
exit 1
|
102
134
|
end
|
103
135
|
|
104
136
|
|
@@ -106,7 +138,11 @@ module Picobox
|
|
106
138
|
long_desc <<-LONGDESC
|
107
139
|
LONGDESC
|
108
140
|
def start()
|
141
|
+
Picobox.set_verbosity options[:verbose]
|
142
|
+
|
109
143
|
System.new(Os::CurrentOs.get).start
|
144
|
+
rescue SignalException
|
145
|
+
exit 1
|
110
146
|
end
|
111
147
|
|
112
148
|
|
@@ -114,7 +150,11 @@ module Picobox
|
|
114
150
|
long_desc <<-LONGDESC
|
115
151
|
LONGDESC
|
116
152
|
def stop()
|
153
|
+
Picobox.set_verbosity options[:verbose]
|
154
|
+
|
117
155
|
System.new(Os::CurrentOs.get).stop
|
156
|
+
rescue SignalException
|
157
|
+
exit 1
|
118
158
|
end
|
119
159
|
|
120
160
|
|
@@ -122,7 +162,11 @@ module Picobox
|
|
122
162
|
long_desc <<-LONGDESC
|
123
163
|
LONGDESC
|
124
164
|
def restart()
|
165
|
+
Picobox.set_verbosity options[:verbose]
|
166
|
+
|
125
167
|
System.new(Os::CurrentOs.get).restart
|
168
|
+
rescue SignalException
|
169
|
+
exit 1
|
126
170
|
end
|
127
171
|
|
128
172
|
|
@@ -130,7 +174,9 @@ module Picobox
|
|
130
174
|
long_desc <<-LONGDESC
|
131
175
|
LONGDESC
|
132
176
|
def ssh(service)
|
133
|
-
System.new(Os::CurrentOs.get).
|
177
|
+
System.new(Os::CurrentOs.get).ssh service
|
178
|
+
rescue SignalException
|
179
|
+
exit 1
|
134
180
|
end
|
135
181
|
|
136
182
|
|
@@ -139,6 +185,8 @@ module Picobox
|
|
139
185
|
LONGDESC
|
140
186
|
def boxes()
|
141
187
|
Box.new(Os::CurrentOs.get).list
|
188
|
+
rescue SignalException
|
189
|
+
exit 1
|
142
190
|
end
|
143
191
|
|
144
192
|
|
@@ -147,17 +195,21 @@ module Picobox
|
|
147
195
|
LONGDESC
|
148
196
|
def status()
|
149
197
|
system "docker-compose ps"
|
198
|
+
rescue SignalException
|
199
|
+
exit 1
|
150
200
|
end
|
151
201
|
|
152
202
|
|
153
|
-
desc '
|
203
|
+
desc 'reset', 'reset picobox containers'
|
154
204
|
long_desc <<-LONGDESC
|
155
205
|
LONGDESC
|
156
|
-
def
|
206
|
+
def reset()
|
157
207
|
display_info('Cleaning stopped containers', :green)
|
158
208
|
display_status('execute', 'container prune')
|
159
209
|
system "docker container prune"
|
160
210
|
system "docker volume prune"
|
211
|
+
rescue SignalException
|
212
|
+
exit 1
|
161
213
|
end
|
162
214
|
end
|
163
215
|
end
|
@@ -6,7 +6,6 @@ module Picobox
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def visit_darwin subject
|
9
|
-
@os = subject.os
|
10
9
|
publish_event :add_box_start, type
|
11
10
|
|
12
11
|
raise Errors::ProjectNotInitialized unless project_initialized?
|
@@ -14,8 +13,13 @@ module Picobox
|
|
14
13
|
Boxes::Unpacker.new(os).unpack(type)
|
15
14
|
end
|
16
15
|
|
16
|
+
|
17
|
+
def visit_linux subject
|
18
|
+
visit_darwin subject
|
19
|
+
end
|
20
|
+
|
17
21
|
private
|
18
|
-
attr_reader :
|
22
|
+
attr_reader :type
|
19
23
|
|
20
24
|
def project_initialized?() Utils::Project.new(os).project_initialized? end
|
21
25
|
end
|
@@ -6,7 +6,6 @@ module Picobox
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def visit_darwin subject
|
9
|
-
@os = subject.os
|
10
9
|
publish_event :add_service_start, service
|
11
10
|
|
12
11
|
raise Errors::ProjectNotInitialized unless project_initialized?
|
@@ -16,8 +15,13 @@ module Picobox
|
|
16
15
|
publish_event :add_service_completed, service
|
17
16
|
end
|
18
17
|
|
18
|
+
|
19
|
+
def visit_linux subject
|
20
|
+
visit_darwin subject
|
21
|
+
end
|
22
|
+
|
19
23
|
private
|
20
|
-
attr_reader :
|
24
|
+
attr_reader :service
|
21
25
|
|
22
26
|
def project_initialized?() Utils::Project.new(os).project_initialized? end
|
23
27
|
end
|
@@ -6,7 +6,14 @@ module Picobox
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def visit_darwin subject
|
9
|
-
|
9
|
+
publish_event :build_service_start, service
|
10
|
+
system "docker-compose build #{service} #{Picobox.output}"
|
11
|
+
publish_event :build_service_stop
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
def visit_linux subject
|
16
|
+
visit_darwin subject
|
10
17
|
end
|
11
18
|
|
12
19
|
private
|
@@ -1,17 +1,35 @@
|
|
1
1
|
module Picobox
|
2
2
|
module Commands
|
3
3
|
class DownloadDocker < Picobox::Utils::VisitorByOs
|
4
|
-
def visit_darwin subject
|
5
|
-
unless
|
6
|
-
stream = open(
|
4
|
+
def visit_darwin subject
|
5
|
+
unless os.docker_installed?
|
6
|
+
stream = open(os.docker_url,
|
7
7
|
content_length_proc: lambda { |total| publish_event :download_docker_start, total },
|
8
|
-
progress_proc: lambda { |step| publish_event :
|
8
|
+
progress_proc: lambda { |step| publish_event :download_progress, step }
|
9
9
|
)
|
10
10
|
|
11
|
-
IO.copy_stream( stream,
|
11
|
+
IO.copy_stream( stream, os.docker_installer )
|
12
12
|
publish_event :download_docker_complete
|
13
13
|
end
|
14
14
|
end
|
15
|
+
|
16
|
+
|
17
|
+
def visit_linux subject
|
18
|
+
unless os.docker_compose_installed?
|
19
|
+
stream = open(os.docker_compose_url,
|
20
|
+
content_length_proc: lambda { |total| publish_event :download_docker_compose_start, total },
|
21
|
+
progress_proc: lambda { |step| publish_event :download_progress, step }
|
22
|
+
)
|
23
|
+
|
24
|
+
IO.copy_stream( stream, "#{os.tmp_dir}/docker_compose" )
|
25
|
+
publish_event :download_docker_compose_complete
|
26
|
+
|
27
|
+
system("#{os.su} 'mv #{os.tmp_dir}/docker_compose #{os.docker_compose}'")
|
28
|
+
TTY::File.chmod(os.docker_compose, 'u=x')
|
29
|
+
else
|
30
|
+
publish_event :docker_present, os.docker_compose_version?
|
31
|
+
end
|
32
|
+
end
|
15
33
|
end
|
16
34
|
end
|
17
35
|
end
|
@@ -2,9 +2,15 @@ module Picobox
|
|
2
2
|
module Commands
|
3
3
|
class FinishInstall < Picobox::Utils::VisitorByOs
|
4
4
|
def visit_darwin subject
|
5
|
+
publish_event :add_post_install_message, 'You should reload open shells to pick up shell changes'
|
5
6
|
publish_event :install_complete
|
6
7
|
publish_event :post_install_messages
|
7
8
|
end
|
9
|
+
|
10
|
+
|
11
|
+
def visit_linux subject
|
12
|
+
visit_darwin subject
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|