dory 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 32d77f426394ec85bbbe2bab82c51827a606b5f3
4
- data.tar.gz: 3c1f263e12aeb27daa447956eafd76cb8d2784af
3
+ metadata.gz: 044e607a99a4f25539f2cc21b25bdd44967dbbb3
4
+ data.tar.gz: bb755b5e86eacfd5d50d4b2e689cd9899e09cd0e
5
5
  SHA512:
6
- metadata.gz: 4b6628655fa991c06bf885fac5e5e51a9e8529d0cf2e7ab89e9ac71d0ce4770f37e34ace70b03697f5c909b707e84bab711305387a31c62d2a62c6fe857fcb93
7
- data.tar.gz: 32bcb7f13b507fb798f6e4882f4a4640edd31630e5a3b7578a3416273650001ffbe9d9f57850bcf56566f9a8e66e001158bcb74c558190b7540453daeb4fea26
6
+ metadata.gz: 33a1572f8e8d9d7602f131d87dd950c590b82975ba719c079707161864de56af9f9fbe1e7b6b2c74b9b1527e575ec252ed423d9710d4e9f07e16e289a646d71e
7
+ data.tar.gz: c614e5556ec5ae284334ac52dea2cc067f7a73a88aaf5a075602eda509ca7ad28cee0224faeaecc2cee633a700f5bedd86ac61afe43f11e1385da875e7314daa
data/bin/dory CHANGED
@@ -113,7 +113,7 @@ class DoryBin < Thor
113
113
  def exec_up(options)
114
114
  puts "Reading settings file at '#{Dory::Config.filename}'".green if options[:verbose]
115
115
  settings = Dory::Config.settings
116
- if settings[:dory][:nginx_proxy][:enabled]
116
+ if nginx_proxy_enabled?(settings)
117
117
  puts "nginx_proxy enabled in config file".green if options[:verbose]
118
118
  if Dory::Proxy.start
119
119
  puts "Successfully started nginx proxy".green
@@ -124,7 +124,7 @@ class DoryBin < Thor
124
124
  puts "nginx_proxy disabled in config file".yellow
125
125
  end
126
126
 
127
- if settings[:dory][:dnsmasq][:enabled]
127
+ if dnsmasq_enabled?(settings)
128
128
  puts "dnsmasq enabled in config file".green if options[:verbose]
129
129
  if Dory::Dnsmasq.start
130
130
  puts "Successfully started dnsmasq".green
@@ -135,7 +135,7 @@ class DoryBin < Thor
135
135
  puts "dnsmasq disabled in config file".yellow
136
136
  end
137
137
 
138
- if settings[:dory][:resolv][:enabled]
138
+ if resolv_enabled?(settings)
139
139
  if Dory::Resolv.configure
140
140
  puts "Successfully configured local resolver".green
141
141
  else
@@ -148,11 +148,12 @@ class DoryBin < Thor
148
148
  end
149
149
 
150
150
  def exec_status(_options)
151
+ puts "Reading settings file at '#{Dory::Config.filename}'".green if options[:verbose]
151
152
  settings = Dory::Config.settings
152
153
 
153
154
  if Dory::Proxy.running?
154
155
  puts "[*] Nginx proxy: Running as docker container #{Dory::Proxy.container_name}".green
155
- elsif !settings[:dory][:nginx_proxy][:enabled]
156
+ elsif !nginx_proxy_enabled?(settings)
156
157
  puts "[*] Nginx proxy is disabled in config file".yellow
157
158
  else
158
159
  puts "[*] Nginx proxy is not running".red
@@ -160,7 +161,7 @@ class DoryBin < Thor
160
161
 
161
162
  if Dory::Dnsmasq.running?
162
163
  puts "[*] Dnsmasq: Running as docker container #{Dory::Dnsmasq.container_name}".green
163
- elsif !settings[:dory][:dnsmasq][:enabled]
164
+ elsif !dnsmasq_enabled?(settings)
164
165
  puts "[*] Dnsmasq is disabled in config file".yellow
165
166
  else
166
167
  puts "[*] Dnsmasq is not running".red
@@ -168,7 +169,7 @@ class DoryBin < Thor
168
169
 
169
170
  if Dory::Resolv.has_our_nameserver?
170
171
  puts "[*] Resolv: configured with #{Dory::Resolv.file_nameserver_line}".green
171
- elsif !settings[:dory][:resolv][:enabled]
172
+ elsif !resolv_enabled?(settings)
172
173
  puts "[*] Resolv is disabled in config file".yellow
173
174
  else
174
175
  puts "[*] Resolv is not configured".red
@@ -176,38 +177,77 @@ class DoryBin < Thor
176
177
  end
177
178
 
178
179
  def exec_down(options)
180
+ puts "Reading settings file at '#{Dory::Config.filename}'".green if options[:verbose]
181
+ settings = Dory::Config.settings
182
+
179
183
  if Dory::Resolv.clean
180
- puts "nameserver removed from resolv file".green
184
+ if resolv_enabled?(settings)
185
+ puts "nameserver removed from resolv file".green
186
+ else
187
+ puts "Resolv disabled in config file".yellow
188
+ end
181
189
  else
182
190
  puts "Unable to remove nameserver from resolv file".red
183
191
  end
184
192
 
185
193
  if Dory::Dnsmasq.stop
186
- puts "Dnsmasq container stopped".green
187
- if options[:destroy]
188
- if Dory::Dnsmasq.delete
189
- puts "Dnsmasq container successfully deleted".green
190
- else
191
- puts "Dnsmasq container failed to delete".red
194
+ if dnsmasq_enabled?(settings)
195
+ puts "Dnsmasq container stopped".green
196
+ if options[:destroy]
197
+ if Dory::Dnsmasq.delete
198
+ puts "Dnsmasq container successfully deleted".green
199
+ else
200
+ puts "Dnsmasq container failed to delete".red
201
+ end
192
202
  end
203
+ else
204
+ puts "dnsmasq disabled in config file".yellow
193
205
  end
194
206
  else
195
207
  puts "Dnsmasq container failed to stop".red
196
208
  end
197
209
 
198
210
  if Dory::Proxy.stop
199
- puts "Nginx proxy stopped".green
200
- if options[:destroy]
201
- if Dory::Proxy.delete
202
- puts "Nginx proxy container successfully deleted".green
203
- else
204
- puts "Nginx proxy container failed to delete".red
211
+ if nginx_proxy_enabled?(settings)
212
+ puts "Nginx proxy stopped".green
213
+ if options[:destroy]
214
+ if Dory::Proxy.delete
215
+ puts "Nginx proxy container successfully deleted".green
216
+ else
217
+ puts "Nginx proxy container failed to delete".red
218
+ end
205
219
  end
220
+ else
221
+ puts "Nginx proxy disabled in config file".yellow
206
222
  end
207
223
  else
208
224
  puts "Nginx proxy failed to stop".red
209
225
  end
210
226
  end
227
+
228
+ def nginx_proxy_enabled?(settings)
229
+ settings[:dory][:nginx_proxy][:enabled]
230
+ end
231
+
232
+ def nginx_proxy_disabled?(settings)
233
+ !nginx_proxy_enabled?(settings)
234
+ end
235
+
236
+ def dnsmasq_enabled?(settings)
237
+ settings[:dory][:dnsmasq][:enabled]
238
+ end
239
+
240
+ def dnsmasq_disabled?(settings)
241
+ !dnsmasq_enabled?(settings)
242
+ end
243
+
244
+ def resolv_enabled?(settings)
245
+ settings[:dory][:resolv][:enabled]
246
+ end
247
+
248
+ def resolv_disabled?(settings)
249
+ !resolv_enabled?(settings)
250
+ end
211
251
  end
212
252
 
213
253
  aliases = {
@@ -14,15 +14,17 @@ module Dory
14
14
 
15
15
  def start(handle_error: true)
16
16
  if self.running?
17
- puts "Container '#{self.container_name}' is already running"
17
+ if Dory::Config.debug?
18
+ puts "[DEBUG] Container '#{self.container_name}' is already running. Doing nothing"
19
+ end
18
20
  else
19
21
  self.run_preconditions
20
22
  if self.container_exists?
21
- puts "[DEBUG] Container '#{self.container_name}' exists. Deleting"
22
- self.delete
23
+ puts "[DEBUG] Container '#{self.container_name}' exists. Deleting" if Dory::Config.debug?
24
+ self.delete
23
25
  end
24
26
  if Dory::Config.debug?
25
- puts "[DEBUG] does not exist. Creating/starting " \
27
+ puts "[DEBUG] '#{self.container_name} does not exist. Creating/starting " \
26
28
  "'#{self.container_name}' with '#{self.run_command}'"
27
29
  end
28
30
  status = Sh.run_command(self.run_command)
@@ -81,7 +81,7 @@ module Dory
81
81
  end
82
82
 
83
83
  def self.contents_has_our_nameserver?(contents)
84
- !!((contents =~ /#{self.file_comment}/) || (contents =~ /#{self.file_nameserver_line}/))
84
+ !!((contents =~ /#{self.file_comment}/) && (contents =~ /#{self.file_nameserver_line}/))
85
85
  end
86
86
  end
87
87
  end
@@ -1,4 +1,4 @@
1
1
  module Dory
2
- VERSION = '0.2.1'
3
- DATE = '2016-06-09'
2
+ VERSION = '0.2.2'
3
+ DATE = '2016-06-23'
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.1
4
+ version: 0.2.2
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-09 00:00:00.000000000 Z
11
+ date: 2016-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: colorize