small-ops 0.0.34 → 0.0.35
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.
- data/bin/fige +20 -6
- metadata +1 -1
data/bin/fige
CHANGED
|
@@ -29,6 +29,12 @@ OptionParser.new do |opts|
|
|
|
29
29
|
opts.on("-u","--update","pull container") do |p|
|
|
30
30
|
@options[:update]=p
|
|
31
31
|
end
|
|
32
|
+
opts.on("-a","--apend cmd","Append cmd to docker command, before the '-t repo/image'") do |a|
|
|
33
|
+
@options[:append]=a
|
|
34
|
+
end
|
|
35
|
+
opts.on("-n","--dry","Dry run, does no execute only echo commands") do |n|
|
|
36
|
+
@options[:dry]=true
|
|
37
|
+
end
|
|
32
38
|
end.parse!
|
|
33
39
|
|
|
34
40
|
file = @options[:input] || 'fig.yml'
|
|
@@ -54,8 +60,10 @@ apps.each {|k|
|
|
|
54
60
|
yml[k]['name'] = yml[k]['image'].gsub(/[^\/]+\//,'')
|
|
55
61
|
end
|
|
56
62
|
|
|
57
|
-
|
|
58
|
-
|
|
63
|
+
if !@options[:dry] then
|
|
64
|
+
puts `docker stop #{yml[k]['name']} 2> /dev/null`
|
|
65
|
+
puts `docker rm #{yml[k]['name']} 2> /dev/null`
|
|
66
|
+
end
|
|
59
67
|
|
|
60
68
|
if !yml[k].has_key? "environment" then
|
|
61
69
|
yml[k]['environment'] = {}
|
|
@@ -103,6 +111,10 @@ apps.each {|k|
|
|
|
103
111
|
cmd << " -e \"#{d}\" "
|
|
104
112
|
}
|
|
105
113
|
end
|
|
114
|
+
|
|
115
|
+
if @options[:append] then
|
|
116
|
+
cmd << @options[:append]
|
|
117
|
+
end
|
|
106
118
|
|
|
107
119
|
cmd << " -t #{yml[k]['image']} "
|
|
108
120
|
|
|
@@ -110,14 +122,16 @@ apps.each {|k|
|
|
|
110
122
|
cmd << " #{yml[k]["command"]} "
|
|
111
123
|
end
|
|
112
124
|
|
|
113
|
-
if @options[:update] then
|
|
125
|
+
if !@options[:dray] && @options[:update] then
|
|
114
126
|
`docker pull #{yml[k]['image']} > /dev/null 2>&1`
|
|
115
127
|
end
|
|
116
128
|
|
|
117
129
|
puts cmd
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
130
|
+
if !@options[:dry] then
|
|
131
|
+
cid = `#{cmd}`
|
|
132
|
+
@options[:containers].push(cid)
|
|
133
|
+
puts "#{yml[k]['name']} = #{cid}"
|
|
134
|
+
end
|
|
121
135
|
|
|
122
136
|
if @options[:cmd] then
|
|
123
137
|
puts `#{@options[:cmd]}`
|