dust-deploy 0.16.0 → 0.16.1
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/changelog.md +8 -0
- data/lib/dust/server.rb +23 -10
- data/lib/dust/version.rb +1 -1
- metadata +2 -3
- data/lib/dust/recipes/cjdroute.rb +0 -209
data/changelog.md
CHANGED
data/lib/dust/server.rb
CHANGED
@@ -170,26 +170,32 @@ module Dust
|
|
170
170
|
|
171
171
|
# if in sudo mode, copy file to temporary place, then move using sudo
|
172
172
|
if @node['sudo']
|
173
|
-
|
174
|
-
return msg.failed('could not create temporary
|
173
|
+
tmpdir = mktemp(:type => 'directory')
|
174
|
+
return msg.failed('could not create temporary directory (needed for sudo)') unless tmpdir
|
175
|
+
|
176
|
+
# temporary destination in tmpdir
|
177
|
+
tmpdest = "#{tmpdir}/#{File.basename(destination)}"
|
175
178
|
|
176
179
|
# allow user to write file without sudo (for scp)
|
177
180
|
# then change file back to root, and copy to the destination
|
178
|
-
chown(@node['user'],
|
179
|
-
@ssh.scp.upload!(source,
|
181
|
+
chown(@node['user'], tmpdir, :quiet => true)
|
182
|
+
@ssh.scp.upload!(source, tmpdest, :recursive => true)
|
180
183
|
|
181
184
|
# set file permissions
|
182
|
-
chown("#{user}:#{group}",
|
183
|
-
chmod(permissions,
|
185
|
+
chown("#{user}:#{group}", tmpdest, :quiet => true) if user and group
|
186
|
+
chmod(permissions, tmpdest, :quiet => true)
|
184
187
|
|
185
188
|
# if destination is a directory, append real filename
|
186
189
|
destination = "#{destination}/#{File.basename(source)}" if is_dir
|
187
190
|
|
188
191
|
# move the file from the temporary location to where it actually belongs
|
189
|
-
msg.parse_result(exec("mv -f #{
|
192
|
+
msg.parse_result(exec("mv -f #{tmpdest} #{destination}")[:exit_code])
|
193
|
+
|
194
|
+
# remove temporary directory
|
195
|
+
rm(tmpdir, :quiet => true)
|
190
196
|
|
191
197
|
else
|
192
|
-
@ssh.scp.upload!(source, destination)
|
198
|
+
@ssh.scp.upload!(source, destination, :recursive => true)
|
193
199
|
msg.ok
|
194
200
|
|
195
201
|
# set file permissions
|
@@ -869,8 +875,15 @@ module Dust
|
|
869
875
|
end
|
870
876
|
|
871
877
|
# create a temporary file
|
872
|
-
def mktemp
|
873
|
-
|
878
|
+
def mktemp(options = { :type => 'file' })
|
879
|
+
if options[:type] == 'file'
|
880
|
+
ret = exec('mktemp --tmpdir dust.XXXXXXXXXX')
|
881
|
+
elsif options[:type] == 'directory'
|
882
|
+
ret = exec('mktemp -d --tmpdir dust.XXXXXXXXXX')
|
883
|
+
else
|
884
|
+
return messages.add("mktemp: unknown type '#{options[:type]}'").failed
|
885
|
+
end
|
886
|
+
|
874
887
|
return false if ret[:exit_code] != 0
|
875
888
|
ret[:stdout].chomp
|
876
889
|
end
|
data/lib/dust/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dust-deploy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.16.
|
4
|
+
version: 0.16.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
@@ -169,7 +169,6 @@ files:
|
|
169
169
|
- lib/dust/recipes/aliases.rb
|
170
170
|
- lib/dust/recipes/apt.rb
|
171
171
|
- lib/dust/recipes/chrony.rb
|
172
|
-
- lib/dust/recipes/cjdroute.rb
|
173
172
|
- lib/dust/recipes/cron.rb
|
174
173
|
- lib/dust/recipes/cups_client.rb
|
175
174
|
- lib/dust/recipes/debsecan.rb
|
@@ -1,209 +0,0 @@
|
|
1
|
-
require 'json'
|
2
|
-
|
3
|
-
class Cjdroute< Recipe
|
4
|
-
desc 'cjdroute:deploy', 'installs / updates cjdns'
|
5
|
-
def deploy
|
6
|
-
# apply default configuration
|
7
|
-
@config = default_config.merge @config
|
8
|
-
|
9
|
-
return unless install_dependencies
|
10
|
-
return unless get_latest_version
|
11
|
-
|
12
|
-
# compiling action
|
13
|
-
return unless run_make
|
14
|
-
|
15
|
-
# create the config file and place it into etc_dir
|
16
|
-
return unless generate_config
|
17
|
-
|
18
|
-
if options.restart?
|
19
|
-
stop_cjdroute
|
20
|
-
|
21
|
-
# copy binary
|
22
|
-
return unless @node.mkdir(@config['bin_dir'])
|
23
|
-
return unless @node.cp("#{@config['build_dir']}/cjdroute", "#{@config['bin_dir']}/cjdroute")
|
24
|
-
|
25
|
-
start_cjdroute
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
|
30
|
-
private
|
31
|
-
def default_config
|
32
|
-
{
|
33
|
-
'git_repo' => 'git://github.com/cjdelisle/cjdns.git',
|
34
|
-
'git_branch' => 'master',
|
35
|
-
'build_dir' => '/tmp/cjdns-tmp',
|
36
|
-
'bin_dir' => '/usr/local/bin',
|
37
|
-
'etc_dir' => '/etc/cjdns/',
|
38
|
-
'tun' => 'cjdroute0',
|
39
|
-
'loglevel' => 'INFO'
|
40
|
-
}
|
41
|
-
end
|
42
|
-
|
43
|
-
def public_peers
|
44
|
-
# list of public peers, taken from https://wiki.projectmeshnet.org/Public_peers
|
45
|
-
{
|
46
|
-
# greys nodes
|
47
|
-
'199.180.252.227:19071' => {
|
48
|
-
'password' => 'public_JFh4rX0R1jm6a7eKWCzD',
|
49
|
-
'publicKey' => '425bcpr9ns0jpuh9ffx1lbbktkd3tpln16jzs9sgbjdkvfg25zv0.k'
|
50
|
-
},
|
51
|
-
|
52
|
-
'80.83.121.61:19071' => {
|
53
|
-
'password' => 'public_2bHnV12c5HRgKddJ1ebv',
|
54
|
-
'publicKey' => 'n5502gtrr9zhj1m0lxm151fqd5mctw68hp64m61dj1mx7w7kvr30.k'
|
55
|
-
},
|
56
|
-
|
57
|
-
# derps nodes
|
58
|
-
'173.255.219.67:10000' => {
|
59
|
-
'password' => 'null',
|
60
|
-
'publicKey' => 'lj52930v1vmg3jqyb399us501svntt499bvgk0c1fud4pmy42gj0.k'
|
61
|
-
},
|
62
|
-
|
63
|
-
'96.126.112.124:10000' => {
|
64
|
-
'password' => 'null',
|
65
|
-
'publicKey' => '7zy1gb9bw4xp82kjvh66w01jdgh6y3lk7cfnl0pgb0xnn26b2jn0.k'
|
66
|
-
},
|
67
|
-
|
68
|
-
# rainfly x
|
69
|
-
'76.105.229.241:13982' => {
|
70
|
-
'password' => 'general_public_1985',
|
71
|
-
'publicKey' => '7pu8nlqphgd1bux9sdpjg0c104217r3b3m1bvmdtbn7uwcj5cky0.k'
|
72
|
-
},
|
73
|
-
|
74
|
-
# ds500ss
|
75
|
-
'87.208.234.24:28078' => {
|
76
|
-
'password' => 'freedomnetsrai9yah4Kic5Kojah5que4xoCh',
|
77
|
-
'publicKey' => 'qb426vh42usw995jy60ll6rtslguv1ylpvwp44ymzky6f0u5qvq0.k'
|
78
|
-
},
|
79
|
-
|
80
|
-
# Dans nodes
|
81
|
-
'199.83.100.24:41902' => {
|
82
|
-
'password' => 'znuhtpf005705tp8snzbywynm6',
|
83
|
-
'publicKey' => 'xltnfur6xh2n36g79y1qpht910c13sq7lb049662x7trfx3gf190.k'
|
84
|
-
},
|
85
|
-
|
86
|
-
'173.192.138.43:26099' => {
|
87
|
-
'password' => 'fjhgf77nsnsp8mrkvyxbwj5jw0',
|
88
|
-
'publicKey' => 'bzmd25v05dctt77nqlgl8rxm24g0q8hwlkkcc64ss7pybbx2ndg0.k'
|
89
|
-
},
|
90
|
-
|
91
|
-
'74.221.208.153:51674' => {
|
92
|
-
'password' => 'jljwnfutfpt1nz3yjsj0dscpf7',
|
93
|
-
'publicKey' => '8hgr62ylugxjyyhxkz254qtz60p781kbswmhhywtbb5rpzc5lxj0.k'
|
94
|
-
}
|
95
|
-
}
|
96
|
-
end
|
97
|
-
|
98
|
-
# installs cmake, git and other building tools needed
|
99
|
-
def install_dependencies
|
100
|
-
@node.messages.add("installing build dependencies\n")
|
101
|
-
|
102
|
-
return false unless @node.install_package('cmake', :indent => 2)
|
103
|
-
|
104
|
-
# check cmake version
|
105
|
-
ret = @node.exec('cmake --version')
|
106
|
-
ver = ret[:stdout].match(/2.[0-9]/)[0].to_f
|
107
|
-
return @node.messages.add('cjdroute requires cmake 2.8 or higher').failed if ver < 2.8
|
108
|
-
|
109
|
-
|
110
|
-
if @node.uses_apt?
|
111
|
-
return false unless @node.install_package('git-core', :indent => 2)
|
112
|
-
return false unless @node.install_package('build-essential', :indent => 2)
|
113
|
-
return false unless @node.install_package('psmisc', :indent => 2)
|
114
|
-
return false unless @node.install_package('coreutils', :indent => 2)
|
115
|
-
else
|
116
|
-
return false unless @node.install_package('git', :indent => 2)
|
117
|
-
return false unless @node.install_package('gcc', :indent => 2)
|
118
|
-
return false unless @node.install_package('make', :indent => 2)
|
119
|
-
end
|
120
|
-
|
121
|
-
true
|
122
|
-
end
|
123
|
-
|
124
|
-
# gets/updates latest version from cjdns git repository
|
125
|
-
def get_latest_version
|
126
|
-
if @node.dir_exists?(@config['build_dir'], :quiet => true)
|
127
|
-
|
128
|
-
# check if build directory is maintained by git
|
129
|
-
unless @node.dir_exists?("#{@config['build_dir']}/.git", :quiet => true)
|
130
|
-
return @node.messages.add("#{@config['build_dir']} doesn't appear to be a git repository").failed
|
131
|
-
end
|
132
|
-
|
133
|
-
# git pull latest changes
|
134
|
-
msg = @node.messages.add("checking out branch '#{@config['git_branch']}'")
|
135
|
-
ret = @node.exec("cd #{@config['build_dir']}; git checkout #{@config['git_branch']}")[:exit_code]
|
136
|
-
return unless msg.parse_result(ret)
|
137
|
-
|
138
|
-
msg = @node.messages.add('pulling latest changes from repository')
|
139
|
-
ret = @node.exec("cd #{@config['build_dir']}; git pull", :live => true)[:exit_code]
|
140
|
-
return unless msg.parse_result(ret)
|
141
|
-
|
142
|
-
else
|
143
|
-
# create build directory
|
144
|
-
unless @node.mkdir(@config['build_dir'])
|
145
|
-
return @node.messages.add("couldn't create build directory #{@config['build_dir']}").failed
|
146
|
-
end
|
147
|
-
|
148
|
-
# git clone cjdns repository
|
149
|
-
msg = @node.messages.add("cloning cjdns repository into #{@config['build_dir']}")
|
150
|
-
ret = @node.exec("git clone #{@config['git_repo']} -b #{@config['git_branch']} #{@config['build_dir']}", :live => true)
|
151
|
-
return unless msg.parse_result(ret[:exit_code])
|
152
|
-
end
|
153
|
-
|
154
|
-
# reset to the wanted commit if given
|
155
|
-
if @config['commit']
|
156
|
-
msg = @node.messages.add("resetting to commit: #{@config['commit']}")
|
157
|
-
msg.parse_result(@node.exec("cd #{@config['build_dir']}; git reset --hard #{@config['commit']}")[:exit_code])
|
158
|
-
end
|
159
|
-
|
160
|
-
true
|
161
|
-
end
|
162
|
-
|
163
|
-
def run_make
|
164
|
-
msg = @node.messages.add('compiling cjdns')
|
165
|
-
msg.parse_result(@node.exec("export Log_LEVEL=#{@config['loglevel']}; cd #{@config['build_dir']}; ./do", :live => true)[:exit_code])
|
166
|
-
end
|
167
|
-
|
168
|
-
# generate cjdroute.conf
|
169
|
-
def generate_config
|
170
|
-
if @node.file_exists? "#{@config['etc_dir']}/cjdroute.conf", :quiet => true
|
171
|
-
@node.messages.add('found a cjdroute.conf, not overwriting').warning
|
172
|
-
return true
|
173
|
-
end
|
174
|
-
|
175
|
-
msg = @node.messages.add('generating config file')
|
176
|
-
ret = @node.exec("#{@config['build_dir']}/cjdroute --genconf")
|
177
|
-
return false unless msg.parse_result(ret[:exit_code])
|
178
|
-
|
179
|
-
# parse generated json
|
180
|
-
cjdroute_conf = JSON.parse(ret[:stdout])
|
181
|
-
|
182
|
-
# add some public peers, so we can get started directly
|
183
|
-
msg = @node.messages.add('adding public peers', :indent => 2)
|
184
|
-
cjdroute_conf['interfaces']['UDPInterface']['connectTo'] = public_peers
|
185
|
-
msg.ok
|
186
|
-
|
187
|
-
# exchange tun0 with configured tun device
|
188
|
-
cjdroute_conf['router']['interface']['tunDevice'] = @config['tun']
|
189
|
-
|
190
|
-
return false unless @node.mkdir(@config['etc_dir'])
|
191
|
-
return @node.write("#{@config['etc_dir']}/cjdroute.conf", JSON.pretty_generate(cjdroute_conf))
|
192
|
-
end
|
193
|
-
|
194
|
-
# kill any cjdroute processes that might be running
|
195
|
-
def stop_cjdroute
|
196
|
-
msg = @node.messages.add('stopping cjdroute')
|
197
|
-
msg.parse_result(@node.exec('killall cjdroute')[:exit_code])
|
198
|
-
|
199
|
-
msg = @node.messages.add('waiting 2 seconds for cjdroute to finish')
|
200
|
-
sleep 2
|
201
|
-
msg.ok
|
202
|
-
end
|
203
|
-
|
204
|
-
# fire up cjdroute
|
205
|
-
def start_cjdroute
|
206
|
-
msg = @node.messages.add('fireing up cjdroute')
|
207
|
-
msg.parse_result(@node.exec("nohup #{@config['bin_dir']}/cjdroute < #{@config['etc_dir']}/cjdroute.conf &> /dev/null &")[:exit_code])
|
208
|
-
end
|
209
|
-
end
|