etch 3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +16 -0
- data/bin/etch +101 -0
- data/bin/etch_cron_wrapper +18 -0
- data/bin/etch_to_trunk +45 -0
- data/etc/ca.pem +1 -0
- data/etc/dhparams +9 -0
- data/lib/etch.rb +1391 -0
- data/lib/etchclient.rb +2420 -0
- data/lib/versiontype.rb +84 -0
- data/man/man8/etch.8 +204 -0
- metadata +78 -0
data/lib/versiontype.rb
ADDED
@@ -0,0 +1,84 @@
|
|
1
|
+
# This class stores numbers with multiple decimal points, a format
|
2
|
+
# commonly used for version numbers. For example '2.5.1'.
|
3
|
+
|
4
|
+
class Version
|
5
|
+
include Comparable
|
6
|
+
|
7
|
+
def initialize(version)
|
8
|
+
@version = version.to_s
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_s
|
12
|
+
@version
|
13
|
+
end
|
14
|
+
|
15
|
+
def <=>(other)
|
16
|
+
ourfields = @version.split('.')
|
17
|
+
otherfields = other.to_s.split('.')
|
18
|
+
# Convert anything like '.5' to '0.5'
|
19
|
+
# '.5'.split('.') returns ['', '5']
|
20
|
+
[ourfields, otherfields].each do |fields|
|
21
|
+
if fields[0] == ''
|
22
|
+
fields[0] = '0'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
convert_and_split!(ourfields, otherfields)
|
27
|
+
|
28
|
+
# Array conveniently implements <=>
|
29
|
+
ourfields <=> otherfields
|
30
|
+
end
|
31
|
+
|
32
|
+
# Private methods below
|
33
|
+
private
|
34
|
+
|
35
|
+
|
36
|
+
# Loops over two arrays in parallel. If the entry at a given
|
37
|
+
# position in both arrays is numeric it is converted from a string to
|
38
|
+
# a number, or if either entry is a mixture of numeric and
|
39
|
+
# non-numeric characters then both are split into an array consisting
|
40
|
+
# of the numeric and non-numeric components.
|
41
|
+
def convert_and_split!(fields0, fields1)
|
42
|
+
# Pad the shorter of two arrays with zeros so that both arrays are
|
43
|
+
# the same length. This ensures that '1' == '1.0', etc.
|
44
|
+
if fields0.length != fields1.length
|
45
|
+
larger = [fields0.length, fields1.length].max
|
46
|
+
# For the longer number this depends on something like (3...1).each
|
47
|
+
# doing nothing. That currently works, but is not documented behavior.
|
48
|
+
(fields0.length...larger).each { fields0 << '0' }
|
49
|
+
(fields1.length...larger).each { fields1 << '0' }
|
50
|
+
end
|
51
|
+
|
52
|
+
# Squish both arrays together
|
53
|
+
bothfields = []
|
54
|
+
(0...fields0.length).each { |i| bothfields << [fields0[i], fields1[i]] }
|
55
|
+
|
56
|
+
bothfields.map! do |fields|
|
57
|
+
# Convert fields of all digits from string to number to get a numeric
|
58
|
+
# rather than string comparison. This ensures that 5.9 < 5.10
|
59
|
+
# Unless either start with a zero, as 1.1 != 1.01, but converting
|
60
|
+
# 01 to a number turns it into 1.
|
61
|
+
if fields[0] =~ /^[1-9]\d*$/ && fields[1] =~ /^[1-9]\d*$/
|
62
|
+
fields.map! { |f| f.to_i }
|
63
|
+
else
|
64
|
+
# If the field is a mixture of numeric and non-numeric
|
65
|
+
# characters then split it up into an array of those components
|
66
|
+
# so that we compare "naturally". I.e. 9a < 10a
|
67
|
+
# This is similar to the method used by most "natural sort"
|
68
|
+
# algorithms that aim to sort file9 above file10.
|
69
|
+
if fields[0] =~ /\d\D/ || fields[0] =~ /\D\d/ ||
|
70
|
+
fields[1] =~ /\d\D/ || fields[1] =~ /\D\d/
|
71
|
+
fields.map! { |f| f.scan(/\d+|\D+/) }
|
72
|
+
# Pass back through this method to convert the numeric
|
73
|
+
# entries to numbers
|
74
|
+
convert_and_split!(fields[0], fields[1])
|
75
|
+
end
|
76
|
+
end
|
77
|
+
fields
|
78
|
+
end
|
79
|
+
# Unsquish back to separate arrays
|
80
|
+
fields0.clear
|
81
|
+
fields1.clear
|
82
|
+
bothfields.each { |fields| fields0 << fields[0]; fields1 << fields[1] }
|
83
|
+
end
|
84
|
+
end
|
data/man/man8/etch.8
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
.TH etch 8 "October 2009"
|
2
|
+
|
3
|
+
.SH NAME
|
4
|
+
|
5
|
+
.B etch
|
6
|
+
\- Configuration management for Unix systems
|
7
|
+
|
8
|
+
.SH SYNOPSIS
|
9
|
+
|
10
|
+
.B etch
|
11
|
+
.RB [ --generate-all ]
|
12
|
+
.RB [ --dry-run | \-n ]
|
13
|
+
.RB [ --damp-run ]
|
14
|
+
.RB [ --interactive ]
|
15
|
+
.RB [ --full-file ]
|
16
|
+
.RB [ --filename-only ]
|
17
|
+
.RB [ --disable-force ]
|
18
|
+
.RB [ --lock-force ]
|
19
|
+
.RB [ --debug ]
|
20
|
+
.RB [ --local
|
21
|
+
.IR DIR ]
|
22
|
+
.RB [ --server
|
23
|
+
.IR SERVER ]
|
24
|
+
.RB [ --tag
|
25
|
+
.IR TAG ]
|
26
|
+
.RB [ --test-base
|
27
|
+
.IR TESTDIR ]
|
28
|
+
.RB [ --key
|
29
|
+
.IR PRIVATE_KEY ]
|
30
|
+
.RB [ --version ]
|
31
|
+
.RB [ --help | \-h ]
|
32
|
+
.RI [ "file ..." ]
|
33
|
+
|
34
|
+
.SH DESCRIPTION
|
35
|
+
|
36
|
+
Etch is a tool for managing the configuration of Unix systems. Etch can manage
|
37
|
+
text or binary files, links and directories. The contents of files can be
|
38
|
+
supplied from static files or generated on the fly by scripts or templates.
|
39
|
+
Permissions and ownership as well as any pre or post commands to run when
|
40
|
+
updating the file are configured in simple XML files.
|
41
|
+
|
42
|
+
.SH OPTIONS
|
43
|
+
.TP
|
44
|
+
.B --generate-all
|
45
|
+
Request that the server generate and send over all available configuration.
|
46
|
+
Can be used instead of specifying specific files to request.
|
47
|
+
.TP
|
48
|
+
.B --dry-run | \-n
|
49
|
+
.B etch
|
50
|
+
will not make any changes to the system. Contents of generated config
|
51
|
+
files are displayed instead of being written to disk.
|
52
|
+
.TP
|
53
|
+
.B --damp-run
|
54
|
+
Perform an almost dry run, except that 'setup' entries for files are run.
|
55
|
+
Normally all setup/pre/post entries are ignored for a dry run. However, files
|
56
|
+
with setup entries will generally fail to build properly if the setup entry
|
57
|
+
hasn't been run. This allows you to preview the full and correct
|
58
|
+
configuration while making minimal changes to the system.
|
59
|
+
.TP
|
60
|
+
.B --interactive
|
61
|
+
Causes
|
62
|
+
.B etch
|
63
|
+
to pause before making each change and prompt the user for
|
64
|
+
confirmation.
|
65
|
+
.TP
|
66
|
+
.B --full-file
|
67
|
+
Normally
|
68
|
+
.B etch
|
69
|
+
will print a diff to show what changes it will make to a file. This will cause
|
70
|
+
.B etch
|
71
|
+
to display the full new file contents instead. Useful if the diff is hard to
|
72
|
+
read for a particular file.
|
73
|
+
.TP
|
74
|
+
.B --filename-only
|
75
|
+
Normally
|
76
|
+
.B etch
|
77
|
+
will print a diff to show what changes it will make to a file. This will cause
|
78
|
+
etch to display only the name of file to be changed. Useful on the initial
|
79
|
+
run during your system build process or other times when you want less output.
|
80
|
+
.TP
|
81
|
+
.B --disable-force
|
82
|
+
Ignore the disable_etch file. Use with caution. Typically used with
|
83
|
+
--interactive or --dry-run to evaluate what would happen if etch were
|
84
|
+
re-enabled.
|
85
|
+
.TP
|
86
|
+
.B --lock-force
|
87
|
+
.B Etch
|
88
|
+
does per-file internal locking as it runs to prevent problems with
|
89
|
+
simultaneous instances of the
|
90
|
+
.B etch
|
91
|
+
client stepping on each other.
|
92
|
+
.B Etch
|
93
|
+
automatically cleans up lockfiles over two hours old on the assumption that
|
94
|
+
any lockfiles that old were left behind by a previous instance that failed for
|
95
|
+
some (hopefully transient) reason. In a large environment you don't want to
|
96
|
+
have to run around manually cleaning up lockfiles every time a full disk or
|
97
|
+
unavailable package server or other transient failure causes
|
98
|
+
.B etch
|
99
|
+
to fail
|
100
|
+
temporarily. This option forces the removal of any existing lockfiles no
|
101
|
+
matter how old. Useful if a buggy configuration or local environmental issue
|
102
|
+
caused
|
103
|
+
.B etch
|
104
|
+
to abort and you want to immediately retry.
|
105
|
+
.TP
|
106
|
+
.BI --local " DIR"
|
107
|
+
Read configuration from a local directory rather than requesting it from
|
108
|
+
a server.
|
109
|
+
.TP
|
110
|
+
.BI --server " SERVER"
|
111
|
+
Point
|
112
|
+
.B etch
|
113
|
+
to an alternate server, specified in the form of a URL.
|
114
|
+
.TP
|
115
|
+
.BI --tag " TAG"
|
116
|
+
Request a specific repository tag from the server. Tags are directory paths
|
117
|
+
relative to /etc/etchserver by default. Thus examples might be
|
118
|
+
.I trunk
|
119
|
+
for /etc/etchserver/trunk, or
|
120
|
+
.I branches/mytestbranch
|
121
|
+
for /etc/etchserver/branches/mytestbranch.
|
122
|
+
.TP
|
123
|
+
.BI --key " PRIVATE_KEY"
|
124
|
+
Use an alternate SSH private key file for signing messages that are sent to
|
125
|
+
the server.
|
126
|
+
.TP
|
127
|
+
.BI --test-base " TESTDIR"
|
128
|
+
Use an alternate local working directory instead of /var/etch. Generally only
|
129
|
+
used for allowing the etch test suite to be run as a non-root user.
|
130
|
+
.TP
|
131
|
+
.B --debug
|
132
|
+
Print lots of messages about what etch is doing.
|
133
|
+
.TP
|
134
|
+
.B --version
|
135
|
+
Show the etch client version and exit.
|
136
|
+
.TP
|
137
|
+
.B --help | \-h
|
138
|
+
Display the etch usage message and exit.
|
139
|
+
|
140
|
+
.SH FILES
|
141
|
+
|
142
|
+
.TP
|
143
|
+
.B /etc/etch/ca.pem
|
144
|
+
SSL certificate(s) needed to verify the
|
145
|
+
.B etch
|
146
|
+
server's identity. If
|
147
|
+
.B etch
|
148
|
+
is using a server with an https:// URL and if this file exists then
|
149
|
+
.B etch
|
150
|
+
will not proceed if the server's SSL certificate can't be verified against the
|
151
|
+
certs in this file.
|
152
|
+
.TP
|
153
|
+
.B /etc/etch/dhparams
|
154
|
+
The Diffie-Hellman parameters used as part of the SSL connection process. Etch
|
155
|
+
comes with a set and there's no need to generate your own, but a new set can
|
156
|
+
be generated via "openssl dhparam" if desired. If this file is not present the
|
157
|
+
Ruby SSL library will warn that it is using its internal default set of
|
158
|
+
parameters.
|
159
|
+
.TP
|
160
|
+
.B /var/etch/disable_etch
|
161
|
+
If this file is present
|
162
|
+
.B etch
|
163
|
+
will do nothing other than send a message to the
|
164
|
+
.B etch
|
165
|
+
server that it is disabled. Any text in this file will be included in
|
166
|
+
that message to the server and displayed locally. If you are disabling
|
167
|
+
.B etch
|
168
|
+
always put a note in this file indicating who you are, today's date, and why
|
169
|
+
you are disabling
|
170
|
+
.B etch
|
171
|
+
so that fellow administrators won't have to guess later why
|
172
|
+
.B etch
|
173
|
+
was disabled. Re-enabling
|
174
|
+
.B etch
|
175
|
+
after it has been disabled for a long
|
176
|
+
time can be time-consuming, as the person doing so must review any potential
|
177
|
+
changes that have been queued up and ensure that they won't interfere with the
|
178
|
+
current usage of the system. As such be thoughtful about whether disabling
|
179
|
+
.B etch
|
180
|
+
is necessary, and re-enable it as soon as possible.
|
181
|
+
.TP
|
182
|
+
.B /var/etch/history
|
183
|
+
A revision history of each
|
184
|
+
.B etch
|
185
|
+
managed file, stored using the RCS revision control system.
|
186
|
+
.TP
|
187
|
+
.B /var/etch/locks
|
188
|
+
Directory used by the
|
189
|
+
.B etch
|
190
|
+
internal locking mechanism. See the --lock-force option for more details.
|
191
|
+
.TP
|
192
|
+
.B /var/etch/orig
|
193
|
+
A backup of the original contents of each
|
194
|
+
.B etch
|
195
|
+
managed file as it was before etch first touched it.
|
196
|
+
|
197
|
+
.SH DIAGNOSTICS
|
198
|
+
|
199
|
+
See the --debug option and the server logs.
|
200
|
+
|
201
|
+
.SH AUTHOR
|
202
|
+
|
203
|
+
.B Etch
|
204
|
+
is designed and maintained by Jason Heiss
|
metadata
ADDED
@@ -0,0 +1,78 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: etch
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: "3.12"
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jason Heiss
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-11-14 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: facter
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
description:
|
26
|
+
email: etch-users@lists.sourceforge.net
|
27
|
+
executables:
|
28
|
+
- etch
|
29
|
+
- etch_to_trunk
|
30
|
+
- etch_cron_wrapper
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- bin
|
37
|
+
- bin/etch
|
38
|
+
- bin/etch_cron_wrapper
|
39
|
+
- bin/etch_to_trunk
|
40
|
+
- etc
|
41
|
+
- etc/ca.pem
|
42
|
+
- etc/dhparams
|
43
|
+
- lib
|
44
|
+
- lib/etch.rb
|
45
|
+
- lib/etchclient.rb
|
46
|
+
- lib/versiontype.rb
|
47
|
+
- man
|
48
|
+
- man/man8
|
49
|
+
- man/man8/etch.8
|
50
|
+
- Rakefile
|
51
|
+
has_rdoc: false
|
52
|
+
homepage: http://etch.sourceforge.net
|
53
|
+
post_install_message:
|
54
|
+
rdoc_options: []
|
55
|
+
|
56
|
+
require_paths:
|
57
|
+
- lib
|
58
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: "1.8"
|
63
|
+
version:
|
64
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: "0"
|
69
|
+
version:
|
70
|
+
requirements: []
|
71
|
+
|
72
|
+
rubyforge_project:
|
73
|
+
rubygems_version: 1.3.1
|
74
|
+
signing_key:
|
75
|
+
specification_version: 2
|
76
|
+
summary: Etch system configuration management client
|
77
|
+
test_files: []
|
78
|
+
|