dory 0.2.3 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/dory +122 -60
  3. data/lib/dory/version.rb +2 -2
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32c9e4b0eaede749e6fb0ab53d184ca331a74d80
4
- data.tar.gz: 4db9c23f23df1b83eca58c423dfea1e6ef5a1d92
3
+ metadata.gz: 9980430347948f1151abdb39a42392ab21114200
4
+ data.tar.gz: 407c1ba0e59201032ed2fc34979b2bcfb50d9d5d
5
5
  SHA512:
6
- metadata.gz: 282ca8afe16ac103b1a134a5c2a4fb834d60e7bc70f589e81e7b07cd24e7839b8925b03fd3eefa0065e3d7bd553fdae495ec2ab88348422ac1c61944ac25ffb3
7
- data.tar.gz: 7daa417f20874fcfee2f9bbba23adeada9cc7a30c15353c259f749dd11efb21c1b5348627a3a30a23bb7b27d0d6de2529fd332429c1ef541fa59b9b3f0a400be
6
+ metadata.gz: a80c27a7d3bb2f328eb86cb2fb66330927a9d9565c43730a94dc0cb5d010ead704b4658888d8cd3c317c35b6c518955a2325fdc80329f9796eac665b505ab0b6
7
+ data.tar.gz: 4d9c83fc5edb56bc000c40a2cd5c9b6582be8a416d29d8b5d15b30661d8a22d63436720a047a2d5e452b1df9f259d2d1e0a8738fcf0c37ed3e202cc7b4ab71e0
data/bin/dory CHANGED
@@ -33,10 +33,13 @@ class DoryBin < Thor
33
33
  for your custom domain to the nginx proxy. The local resolver
34
34
  will also be configured to use the dnsmasq instance as a nameserver
35
35
 
36
- > $ dory up
36
+ Optionally, you can pass a list of service names as arguments
37
+ to have only one or two services started.
38
+
39
+ > $ dory up [proxy] [dns] [resolv]
37
40
  LONGDESC
38
- def up
39
- exec_up(options)
41
+ def up(*services)
42
+ exec_up(options, services)
40
43
  end
41
44
 
42
45
  desc 'down', 'Stop all dory services'
@@ -44,11 +47,14 @@ class DoryBin < Thor
44
47
  Stops all dory services. Can optionally pass [-d|--destroy]
45
48
  to destroy the containers when they stop.
46
49
 
47
- > $ dory down [-d|--destroy]
50
+ Optionally, you can pass a list of service names as arguments
51
+ to have only one or two services started.
52
+
53
+ > $ dory down [-d|--destroy] [proxy] [dns] [resolv]
48
54
  LONGDESC
49
55
  option :destroy, type: :boolean, aliases: 'd', default: true
50
- def down
51
- exec_down(options)
56
+ def down(*services)
57
+ exec_down(options, services)
52
58
  end
53
59
 
54
60
  desc 'version', 'Check current installed version of dory'
@@ -63,9 +69,9 @@ class DoryBin < Thor
63
69
  > $ dory restart [-d|--destroy]
64
70
  LONGDESC
65
71
  option :destroy, type: :boolean, aliases: 'd', default: true
66
- def restart
67
- exec_down(options)
68
- exec_up(options)
72
+ def restart(*services)
73
+ exec_down(options, services)
74
+ exec_up(options, services)
69
75
  end
70
76
 
71
77
  desc 'status', 'Report status of the dory services'
@@ -162,40 +168,49 @@ class DoryBin < Thor
162
168
  end
163
169
  end
164
170
 
165
- def exec_up(options)
171
+ def exec_up(options, services)
172
+ services = sanitize_services(services)
173
+ return unless services
174
+
166
175
  puts "Reading settings file at '#{Dory::Config.filename}'".green if options[:verbose]
167
176
  settings = Dory::Config.settings
168
- if nginx_proxy_enabled?(settings)
169
- puts "nginx_proxy enabled in config file".green if options[:verbose]
170
- if Dory::Proxy.start
171
- puts "Successfully started nginx proxy".green
177
+ if services.include?('proxy')
178
+ if nginx_proxy_enabled?(settings)
179
+ puts "nginx_proxy enabled in config file".green if options[:verbose]
180
+ if Dory::Proxy.start
181
+ puts "Successfully started nginx proxy".green
182
+ else
183
+ puts "Error starting nginx proxy".red
184
+ end
172
185
  else
173
- puts "Error starting nginx proxy".red
186
+ puts "nginx_proxy disabled in config file".yellow
174
187
  end
175
- else
176
- puts "nginx_proxy disabled in config file".yellow
177
188
  end
178
189
 
179
- if dnsmasq_enabled?(settings)
180
- puts "dnsmasq enabled in config file".green if options[:verbose]
181
- if Dory::Dnsmasq.start
182
- puts "Successfully started dnsmasq".green
190
+ if services.include?('dns')
191
+ if dnsmasq_enabled?(settings)
192
+ puts "dnsmasq enabled in config file".green if options[:verbose]
193
+ if Dory::Dnsmasq.start
194
+ puts "Successfully started dnsmasq".green
195
+ else
196
+ puts "Error starting dnsmasq".red
197
+ end
183
198
  else
184
- puts "Error starting dnsmasq".red
199
+ puts "dnsmasq disabled in config file".yellow
185
200
  end
186
- else
187
- puts "dnsmasq disabled in config file".yellow
188
201
  end
189
202
 
190
- if resolv_enabled?(settings)
191
- if Dory::Resolv.configure
192
- puts "Successfully configured local resolver".green
203
+ if services.include?('resolv')
204
+ if resolv_enabled?(settings)
205
+ if Dory::Resolv.configure
206
+ puts "Successfully configured local resolver".green
207
+ else
208
+ puts "Error configuring local resolver".red
209
+ end
210
+ puts "resolv enabled in config file".green if options[:verbose]
193
211
  else
194
- puts "Error configuring local resolver".red
212
+ puts "resolv disabled in config file".yellow
195
213
  end
196
- puts "resolv enabled in config file".green if options[:verbose]
197
- else
198
- puts "resolv disabled in config file".yellow
199
214
  end
200
215
  end
201
216
 
@@ -228,52 +243,61 @@ class DoryBin < Thor
228
243
  end
229
244
  end
230
245
 
231
- def exec_down(options)
246
+ def exec_down(options, services)
247
+ services = sanitize_services(services)
248
+ return unless services
249
+
232
250
  puts "Reading settings file at '#{Dory::Config.filename}'".green if options[:verbose]
233
251
  settings = Dory::Config.settings
234
252
 
235
- if Dory::Resolv.clean
236
- if resolv_enabled?(settings)
237
- puts "nameserver removed from resolv file".green
253
+ if services.include?('resolv')
254
+ if Dory::Resolv.clean
255
+ if resolv_enabled?(settings)
256
+ puts "nameserver removed from resolv file".green
257
+ else
258
+ puts "Resolv disabled in config file".yellow
259
+ end
238
260
  else
239
- puts "Resolv disabled in config file".yellow
261
+ puts "Unable to remove nameserver from resolv file".red
240
262
  end
241
- else
242
- puts "Unable to remove nameserver from resolv file".red
243
263
  end
244
264
 
245
- if Dory::Dnsmasq.stop
246
- if dnsmasq_enabled?(settings)
247
- puts "Dnsmasq container stopped".green
248
- if options[:destroy]
249
- if Dory::Dnsmasq.delete
250
- puts "Dnsmasq container successfully deleted".green
251
- else
252
- puts "Dnsmasq container failed to delete".red
265
+ if services.include?('dns')
266
+ if Dory::Dnsmasq.stop
267
+ if dnsmasq_enabled?(settings)
268
+ puts "Dnsmasq container stopped".green
269
+ if options[:destroy]
270
+ if Dory::Dnsmasq.delete
271
+ puts "Dnsmasq container successfully deleted".green
272
+ else
273
+ puts "Dnsmasq container failed to delete".red
274
+ end
253
275
  end
276
+ else
277
+ puts "dnsmasq disabled in config file".yellow
254
278
  end
255
279
  else
256
- puts "dnsmasq disabled in config file".yellow
280
+ puts "Dnsmasq container failed to stop".red
257
281
  end
258
- else
259
- puts "Dnsmasq container failed to stop".red
260
282
  end
261
283
 
262
- if Dory::Proxy.stop
263
- if nginx_proxy_enabled?(settings)
264
- puts "Nginx proxy stopped".green
265
- if options[:destroy]
266
- if Dory::Proxy.delete
267
- puts "Nginx proxy container successfully deleted".green
268
- else
269
- puts "Nginx proxy container failed to delete".red
284
+ if services.include?('proxy')
285
+ if Dory::Proxy.stop
286
+ if nginx_proxy_enabled?(settings)
287
+ puts "Nginx proxy stopped".green
288
+ if options[:destroy]
289
+ if Dory::Proxy.delete
290
+ puts "Nginx proxy container successfully deleted".green
291
+ else
292
+ puts "Nginx proxy container failed to delete".red
293
+ end
270
294
  end
295
+ else
296
+ puts "Nginx proxy disabled in config file".yellow
271
297
  end
272
298
  else
273
- puts "Nginx proxy disabled in config file".yellow
299
+ puts "Nginx proxy failed to stop".red
274
300
  end
275
- else
276
- puts "Nginx proxy failed to stop".red
277
301
  end
278
302
  end
279
303
 
@@ -300,6 +324,44 @@ class DoryBin < Thor
300
324
  def resolv_disabled?(settings)
301
325
  !resolv_enabled?(settings)
302
326
  end
327
+
328
+ def valid_services
329
+ %w[proxy dns resolv]
330
+ end
331
+
332
+ def canonical_service(service)
333
+ {
334
+ 'proxy' => 'proxy',
335
+ 'nginx' => 'proxy',
336
+ 'nginx_proxy' => 'proxy',
337
+ 'nginx-proxy' => 'proxy',
338
+ 'dns' => 'dns',
339
+ 'dnsmasq' => 'dns',
340
+ 'resolv' => 'resolv',
341
+ 'resolve' => 'resolv'
342
+ }[service]
343
+ end
344
+
345
+ def valid_service?(service)
346
+ valid_services.include?(canonical_service(service))
347
+ end
348
+
349
+ def valid_services?(services)
350
+ services.all? do |service|
351
+ if valid_service?(service)
352
+ true
353
+ else
354
+ puts "'#{service}' is not valid. Must be one or more of these: #{valid_services.join(', ')}"
355
+ false
356
+ end
357
+ end
358
+ end
359
+
360
+ def sanitize_services(services)
361
+ return valid_services if !services || services.empty?
362
+ return false unless valid_services?(services)
363
+ services.map{|s| canonical_service(s) }
364
+ end
303
365
  end
304
366
 
305
367
  aliases = {
data/lib/dory/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Dory
2
- VERSION = '0.2.3'
3
- DATE = '2016-06-24'
2
+ VERSION = '0.2.4'
3
+ DATE = '2016-06-28'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dory
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Porter
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-24 00:00:00.000000000 Z
11
+ date: 2016-06-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize