hak 0.5.3 → 0.5.5
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/bin/hak +56 -111
- data/lib/hak.rb +1 -1
- data/lib/hak/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd0f7dee1f2a34c899daeb7ead66035c780bee05
|
|
4
|
+
data.tar.gz: 598cc60eb0e34c4993abf0350be5eb98fa344734
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 28215cc3612f02a526c44e36e84d5f988c4af89d0ce8bbb4fff57648685290dded09bc0cd02c68d984524a8715b99e9fe92512e68e226a0f70ca84a2f7ffe285
|
|
7
|
+
data.tar.gz: d5ce5958e9f75ec9d8381fdbf188352ddc2c6484552766498246a92cb1fdfa135c90acf38740f9a551f0c244f674c464fdfbc94cc035e8aca9564bac331c16f5
|
data/bin/hak
CHANGED
|
@@ -7,60 +7,37 @@ require 'colorize'
|
|
|
7
7
|
require 'highline'
|
|
8
8
|
|
|
9
9
|
program :name, 'hak'
|
|
10
|
-
program :version, '0.5.
|
|
11
|
-
program :description, 'Hak - A Docker
|
|
10
|
+
program :version, '0.5.5'
|
|
11
|
+
program :description, 'Hak - A Docker-driven development platform'
|
|
12
12
|
|
|
13
13
|
default_command :help
|
|
14
14
|
|
|
15
15
|
command :install do |c|
|
|
16
16
|
c.syntax = 'hak install'
|
|
17
|
-
c.summary = 'installs
|
|
18
|
-
c.description = 'installs
|
|
17
|
+
c.summary = 'installs hak'
|
|
18
|
+
c.description = 'installs hak'
|
|
19
19
|
c.example 'description', 'hak install'
|
|
20
20
|
c.action do |args, options|
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
puts "checking to see if ~/.hak exists".blue
|
|
24
|
-
if !Dir.exists?(File.expand_path('~/.hak'))
|
|
25
|
-
puts "- creating ~/.hak".blue
|
|
26
|
-
system "mkdir -p ~/.hak/packages"
|
|
27
|
-
|
|
28
|
-
# install required dependencies
|
|
29
|
-
puts "- setting up docker, docker-machine, docker-compose, xhyve, wget from brew".blue
|
|
30
|
-
|
|
31
|
-
# re-install docker
|
|
32
|
-
system "brew tap codekitchen/dinghy"
|
|
33
|
-
system "brew install dinghy docker docker-machine docker-compose wget docker-machine-driver-xhyve"
|
|
34
|
-
system "brew upgrade dinghy docker docker-machine docker-compose wget docker-machine-driver-xhyve"
|
|
35
|
-
system "brew unlink dinghy docker docker-machine docker-compose wget docker-machine-driver-xhyve"
|
|
36
|
-
system "brew link dinghy docker docker-machine docker-compose wget docker-machine-driver-xhyve"
|
|
37
|
-
system "sudo chown root:wheel $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve"
|
|
38
|
-
system "sudo chmod u+s $(brew --prefix)/opt/docker-machine-driver-xhyve/bin/docker-machine-driver-xhyve"
|
|
39
|
-
system "dinghy create --provider xhyve"
|
|
22
|
+
user = `whoami`.strip
|
|
40
23
|
|
|
24
|
+
if user != "root"
|
|
25
|
+
puts "Hak will automatically resolve all domains that ends in .docker to your docker vm for you."
|
|
26
|
+
puts "To do this, hak requires sudo to place an entry in /etc/resolver/docker, please type:"
|
|
27
|
+
puts "sudo hak install".yellow
|
|
28
|
+
abort
|
|
41
29
|
else
|
|
42
|
-
puts "- it exists, skipping".blue
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
# check if docker is running
|
|
46
|
-
check_docker
|
|
47
30
|
|
|
48
|
-
|
|
49
|
-
|
|
31
|
+
res = `cat > /etc/resolver/docker <<EOL
|
|
32
|
+
nameserver 127.0.0.1
|
|
33
|
+
port 19322`
|
|
50
34
|
|
|
51
|
-
|
|
52
|
-
|
|
35
|
+
puts "hak installed".green
|
|
36
|
+
puts "now turn hak on by typing:"
|
|
37
|
+
puts "hak on".yellow
|
|
53
38
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
c.summary = 'destroys hak server'
|
|
57
|
-
c.description = 'shuts off and destroys the hak server'
|
|
58
|
-
c.example 'description', 'hak destroy'
|
|
59
|
-
c.action do |args, options|
|
|
60
|
-
system "dinghy halt"
|
|
61
|
-
system "dinghy destroy"
|
|
62
|
-
system "rm -rf ~/.hak"
|
|
63
|
-
system "rm -rf ~/.dinghy"
|
|
39
|
+
end
|
|
40
|
+
|
|
64
41
|
end
|
|
65
42
|
end
|
|
66
43
|
|
|
@@ -70,13 +47,11 @@ command :on do |c|
|
|
|
70
47
|
c.description = 'powers on the hak server'
|
|
71
48
|
c.example 'description', 'hak on'
|
|
72
49
|
c.action do |args, options|
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
end
|
|
50
|
+
check_dns
|
|
51
|
+
`docker stop hak-proxy > /dev/null 2>&1`
|
|
52
|
+
`docker rm hak-proxy > /dev/null 2>&1`
|
|
53
|
+
`docker run -d -v /var/run/docker.sock:/tmp/docker.sock:ro -p 80:80 -p 443:443 -p 19322:19322/udp -e CONTAINER_NAME=hak-proxy --name hak-proxy codekitchen/dinghy-http-proxy`
|
|
54
|
+
puts "hak-proxy started"
|
|
80
55
|
end
|
|
81
56
|
end
|
|
82
57
|
|
|
@@ -86,7 +61,9 @@ command :off do |c|
|
|
|
86
61
|
c.description = 'shuts off the hak server'
|
|
87
62
|
c.example 'description', 'hak off'
|
|
88
63
|
c.action do |args, options|
|
|
89
|
-
|
|
64
|
+
`docker stop hak-proxy > /dev/null 2>&1`
|
|
65
|
+
`docker rm hak-proxy > /dev/null 2>&1`
|
|
66
|
+
puts "hak-proxy stopped"
|
|
90
67
|
end
|
|
91
68
|
end
|
|
92
69
|
|
|
@@ -142,7 +119,7 @@ command :start do |c|
|
|
|
142
119
|
c.description = 'this starts up the website'
|
|
143
120
|
c.example 'description', 'hak start'
|
|
144
121
|
c.action do |args, options|
|
|
145
|
-
|
|
122
|
+
check_all
|
|
146
123
|
run "docker-compose up -d && docker-compose logs -f"
|
|
147
124
|
end
|
|
148
125
|
end
|
|
@@ -153,7 +130,7 @@ command :stop do |c|
|
|
|
153
130
|
c.description = 'stops the site'
|
|
154
131
|
c.example 'description', 'hak stop'
|
|
155
132
|
c.action do |args, options|
|
|
156
|
-
|
|
133
|
+
check_all
|
|
157
134
|
run "docker-compose stop"
|
|
158
135
|
end
|
|
159
136
|
end
|
|
@@ -164,7 +141,7 @@ command :restart do |c|
|
|
|
164
141
|
c.description = 'restarts the site'
|
|
165
142
|
c.example 'description', 'hak restart'
|
|
166
143
|
c.action do |args, options|
|
|
167
|
-
|
|
144
|
+
check_all
|
|
168
145
|
run "docker-compose stop"
|
|
169
146
|
run "docker-compose up -d && docker-compose logs -f"
|
|
170
147
|
end
|
|
@@ -176,7 +153,7 @@ command :rm do |c|
|
|
|
176
153
|
c.description = 'deletes docker containers for the project'
|
|
177
154
|
c.example 'description', 'hak rm'
|
|
178
155
|
c.action do |args, options|
|
|
179
|
-
|
|
156
|
+
check_all
|
|
180
157
|
run "docker-compose stop && docker-compose rm -f --all"
|
|
181
158
|
end
|
|
182
159
|
end
|
|
@@ -199,7 +176,7 @@ command :ssh do |c|
|
|
|
199
176
|
c.description = ''
|
|
200
177
|
c.example 'description', 'hak ssh [app]'
|
|
201
178
|
c.action do |args, options|
|
|
202
|
-
|
|
179
|
+
check_all
|
|
203
180
|
|
|
204
181
|
file_name = 'docker-compose.yml'
|
|
205
182
|
config_options = YAML.load_file(file_name)
|
|
@@ -228,14 +205,14 @@ command :ps do |c|
|
|
|
228
205
|
c.description = ''
|
|
229
206
|
c.example 'description', 'hak ps'
|
|
230
207
|
c.action do |args, options|
|
|
231
|
-
|
|
208
|
+
check_all
|
|
232
209
|
|
|
233
210
|
container_names = run('docker ps --format "{{.Names}}"', true)
|
|
234
211
|
lines = container_names.lines
|
|
235
212
|
dinghy_running = false
|
|
236
213
|
sites = lines.map do |line|
|
|
237
214
|
name = line.split('_')[0]
|
|
238
|
-
if name == '
|
|
215
|
+
if name == 'hak-proxy'
|
|
239
216
|
dinghy_running = true
|
|
240
217
|
"proxy"
|
|
241
218
|
else
|
|
@@ -243,23 +220,8 @@ command :ps do |c|
|
|
|
243
220
|
end
|
|
244
221
|
end
|
|
245
222
|
|
|
246
|
-
|
|
247
|
-
puts sites.uniq
|
|
248
|
-
else
|
|
249
|
-
check_docker
|
|
250
|
-
end
|
|
251
|
-
|
|
252
|
-
end
|
|
253
|
-
end
|
|
223
|
+
puts sites.uniq
|
|
254
224
|
|
|
255
|
-
command :upgrade do |c|
|
|
256
|
-
c.syntax = 'hak upgrade'
|
|
257
|
-
c.summary = 'upgrades hak and dinghy'
|
|
258
|
-
c.description = ''
|
|
259
|
-
c.example 'description', 'hak upgrade'
|
|
260
|
-
c.action do |args, options|
|
|
261
|
-
system "gem update hak"
|
|
262
|
-
run "dinghy upgrade"
|
|
263
225
|
end
|
|
264
226
|
end
|
|
265
227
|
|
|
@@ -360,59 +322,42 @@ def run(command, hide=false)
|
|
|
360
322
|
return res
|
|
361
323
|
end
|
|
362
324
|
|
|
325
|
+
def check_all
|
|
326
|
+
check_docker
|
|
327
|
+
check_dns
|
|
328
|
+
check_proxy
|
|
329
|
+
end
|
|
330
|
+
|
|
363
331
|
def check_docker
|
|
364
332
|
|
|
365
|
-
res = `
|
|
366
|
-
if res.include? "
|
|
333
|
+
res = `docker ps`
|
|
334
|
+
if res.include? "Cannot connect to the Docker daemon"
|
|
367
335
|
running = false
|
|
368
336
|
puts "docker not running or stopped"
|
|
369
|
-
puts "
|
|
370
|
-
puts "hak on".yellow
|
|
337
|
+
puts "Please turn on Docker first. If you don't have Docker installed, please install it from Docker's website."
|
|
371
338
|
abort
|
|
372
|
-
else
|
|
373
|
-
running = true
|
|
374
339
|
end
|
|
375
340
|
|
|
376
|
-
return
|
|
341
|
+
return true
|
|
342
|
+
|
|
377
343
|
end
|
|
378
344
|
|
|
379
|
-
def
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
return false
|
|
345
|
+
def check_dns
|
|
346
|
+
if !File.exist?('/etc/resolver/docker')
|
|
347
|
+
puts "hak not installed properly, please type:"
|
|
348
|
+
puts "sudo hak install".yellow
|
|
349
|
+
abort
|
|
385
350
|
end
|
|
386
351
|
return true
|
|
387
352
|
end
|
|
388
353
|
|
|
389
|
-
def
|
|
390
|
-
|
|
391
|
-
if
|
|
392
|
-
puts "
|
|
393
|
-
puts "
|
|
394
|
-
|
|
395
|
-
output_env
|
|
396
|
-
return false
|
|
354
|
+
def check_proxy
|
|
355
|
+
res = `docker ps`
|
|
356
|
+
if !res.include? "hak-proxy"
|
|
357
|
+
puts "proxy not running, please type:"
|
|
358
|
+
puts "hak on".yellow
|
|
359
|
+
abort
|
|
397
360
|
end
|
|
398
361
|
return true
|
|
399
362
|
end
|
|
400
363
|
|
|
401
|
-
def output_env
|
|
402
|
-
|
|
403
|
-
shell = `echo $SHELL`.strip
|
|
404
|
-
|
|
405
|
-
if shell == '/bin/zsh'
|
|
406
|
-
docker_env_exist = `fgrep "export DOCKER_MACHINE_NAME=dinghy" ~/.zshrc |wc -l`.to_i
|
|
407
|
-
if docker_env_exist == 0
|
|
408
|
-
puts "echo '$(dinghy env)' >> ~/.zshrc".yellow
|
|
409
|
-
end
|
|
410
|
-
end
|
|
411
|
-
|
|
412
|
-
if shell == '/bin/bash'
|
|
413
|
-
docker_env_exist = `fgrep "export DOCKER_MACHINE_NAME=dinghy" ~/.bash_profile |wc -l`.to_i
|
|
414
|
-
if docker_env_exist == 0
|
|
415
|
-
puts "echo '$(dinghy env)' >> ~/.bash_profile".yellow
|
|
416
|
-
end
|
|
417
|
-
end
|
|
418
|
-
end
|
data/lib/hak.rb
CHANGED
data/lib/hak/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hak
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.5.
|
|
4
|
+
version: 0.5.5
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- jaequery
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-06-
|
|
11
|
+
date: 2016-06-22 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: commander
|