omnibus-ctl 0.6.0 → 0.6.10

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
- SHA1:
3
- metadata.gz: 7124151190ecb3203434afe79f6f705cc92006ac
4
- data.tar.gz: 2054e06087ef69abeb032265e01fd32dfc5db730
2
+ SHA256:
3
+ metadata.gz: d5a9e7ad1cc7b71b4a63de91b45c0defc0e980a6ec79848339041eecf414493f
4
+ data.tar.gz: b0f98055e5f34965c6d61719f15c0c6231d43345b87b3ed3e65ede350103728f
5
5
  SHA512:
6
- metadata.gz: cd94929d628f632dd24ab41e36e3efba988ce2a0c7193172e1089d48136bbe108a997cc42a5438fd0165a8f3ce469911ddabae3c2965da002561a8084fb581b2
7
- data.tar.gz: 3ce02e9da7978e6d40837d7ccf7e141a67b9447b9837e966b7b1db8d0d66a1007c1e36cf9283a383d9ee384ba41bfe8cd9d1026ff5795f9751dfae3d221cef65
6
+ metadata.gz: 44b9168f26f927b61a68d8a8d9145c6a18d4b6dad0a48e69515544c107dceb6061b2483580ac9582be750b8fd0d893bc5d77d58bd698c35de220240a28db1913
7
+ data.tar.gz: a2035e53d04247a5b8a6cfa5e777d974ec4747960de47e473c92a438e044c91a86c5d000be4db50d4bce2ba8a0f1726633e8740b9e8138c066ab254bde6a0198
data/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
data/bin/omnibus-ctl CHANGED
@@ -7,9 +7,9 @@
7
7
  # Licensed under the Apache License, Version 2.0 (the "License");
8
8
  # you may not use this file except in compliance with the License.
9
9
  # You may obtain a copy of the License at
10
- #
10
+ #
11
11
  # http://www.apache.org/licenses/LICENSE-2.0
12
- #
12
+ #
13
13
  # Unless required by applicable law or agreed to in writing, software
14
14
  # distributed under the License is distributed on an "AS IS" BASIS,
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -17,7 +17,7 @@
17
17
  # limitations under the License.
18
18
  #
19
19
 
20
- require 'omnibus-ctl'
20
+ require "omnibus-ctl"
21
21
 
22
22
  # service name: ARGV[0]
23
23
  # additional modules: ARGV[1]
@@ -1,5 +1,5 @@
1
1
  module Omnibus
2
2
  class Ctl
3
- VERSION = "0.6.0"
3
+ VERSION = "0.6.10".freeze
4
4
  end
5
5
  end
data/lib/omnibus-ctl.rb CHANGED
@@ -15,21 +15,22 @@
15
15
  #
16
16
 
17
17
  require "omnibus-ctl/version"
18
- require 'json'
19
- require 'fileutils'
18
+ require "chef-utils/dist" unless defined?(ChefUtils)
19
+ require "json" unless defined?(JSON)
20
+ require "fileutils" unless defined?(FileUtils)
20
21
 
21
22
  # For license checks
22
- require 'io/console'
23
- require 'io/wait'
23
+ require "io/console"
24
+ require "io/wait"
24
25
 
25
26
  module Omnibus
26
27
  class Ctl
27
28
 
28
- File::umask(022)
29
+ File.umask(022)
29
30
 
30
- SV_COMMAND_NAMES = %w[status up down once pause cont hup alarm int quit
31
+ SV_COMMAND_NAMES = %w{status up down once pause cont hup alarm int quit
31
32
  term kill start stop restart shutdown force-stop
32
- force-reload force-restart force-shutdown check usr1 usr2]
33
+ force-reload force-restart force-shutdown check usr1 usr2}.freeze
33
34
 
34
35
  attr_accessor :name, :display_name, :log_exclude, :base_path, :sv_path,
35
36
  :service_path, :etc_path, :data_path, :log_path, :command_map, :category_command_map,
@@ -37,8 +38,7 @@ module Omnibus
37
38
 
38
39
  attr_reader :backup_dir, :exe_name
39
40
 
40
-
41
- def initialize(name, merge_service_commands=true, disp_name = nil)
41
+ def initialize(name, merge_service_commands = true, disp_name = nil)
42
42
  @name = name
43
43
  @service_commands = merge_service_commands
44
44
  @display_name = disp_name || name
@@ -48,8 +48,8 @@ module Omnibus
48
48
  @log_path = "/var/log/#{name}"
49
49
  @data_path = "/var/opt/#{name}"
50
50
  @etc_path = "/etc/#{name}"
51
- @log_exclude = '(config|lock|@|gzip|tgz|gz)'
52
- @log_path_exclude = ['*/sasl/*']
51
+ @log_exclude = "(config|lock|@|bz2|gz|gzip|tbz2|tgz|txz|xz|zip)"
52
+ @log_path_exclude = ["*/sasl/*"]
53
53
  @fh_output = STDOUT
54
54
  @kill_users = []
55
55
  @verbose = false
@@ -61,101 +61,101 @@ module Omnibus
61
61
  # TODO(ssd) 2017-03-28: Set SVDIR explicitly. Once we fix a bug
62
62
  # in our debian support, where we rely on system-installed
63
63
  # runit, we can likely change this back to ENV.delete("SVDIR")
64
- ENV['SVDIR'] = service_path
64
+ ENV["SVDIR"] = service_path
65
65
 
66
66
  # backwards compat command map that does not have categories
67
- @command_map = { }
67
+ @command_map = {}
68
68
 
69
69
  # categoired commands that we want by default
70
70
  @category_command_map = {
71
71
  "general" => {
72
72
  "show-config" => {
73
- :desc => "Show the configuration that would be generated by reconfigure.",
74
- :arity => 1
73
+ desc: "Show the configuration that would be generated by reconfigure.",
74
+ arity: 1,
75
75
  },
76
76
  "reconfigure" => {
77
- :desc => "Reconfigure the application.",
78
- :arity => 2
77
+ desc: "Reconfigure the application.",
78
+ arity: 2,
79
79
  },
80
80
  "cleanse" => {
81
- :desc => "Delete *all* #{display_name} data, and start from scratch.",
82
- :arity => 2
81
+ desc: "Delete *all* #{display_name} data, and start from scratch.",
82
+ arity: 2,
83
83
  },
84
84
  "uninstall" => {
85
- :arity => 1,
86
- :desc => "Kill all processes and uninstall the process supervisor (data will be preserved)."
85
+ arity: 1,
86
+ desc: "Kill all processes and uninstall the process supervisor (data will be preserved).",
87
87
  },
88
88
  "help" => {
89
- :arity => 1,
90
- :desc => "Print this help message."
91
- }
92
- }
89
+ arity: 1,
90
+ desc: "Print this help message.",
91
+ },
92
+ },
93
93
  }
94
94
  service_command_map = {
95
95
  "service-management" => {
96
96
  "service-list" => {
97
- :arity => 1,
98
- :desc => "List all the services (enabled services appear with a *.)"
97
+ arity: 1,
98
+ desc: "List all the services (enabled services appear with a *.)",
99
99
  },
100
100
  "status" => {
101
- :desc => "Show the status of all the services.",
102
- :arity => 2
101
+ desc: "Show the status of all the services.",
102
+ arity: 2,
103
103
  },
104
104
  "tail" => {
105
- :desc => "Watch the service logs of all enabled services.",
106
- :arity => 2
105
+ desc: "Watch the service logs of all enabled services.",
106
+ arity: 2,
107
107
  },
108
108
  "start" => {
109
- :desc => "Start services if they are down, and restart them if they stop.",
110
- :arity => 2
109
+ desc: "Start services if they are down, and restart them if they stop.",
110
+ arity: 2,
111
111
  },
112
112
  "stop" => {
113
- :desc => "Stop the services, and do not restart them.",
114
- :arity => 2
113
+ desc: "Stop the services, and do not restart them.",
114
+ arity: 2,
115
115
  },
116
116
  "restart" => {
117
- :desc => "Stop the services if they are running, then start them again.",
118
- :arity => 2
117
+ desc: "Stop the services if they are running, then start them again.",
118
+ arity: 2,
119
119
  },
120
120
  "once" => {
121
- :desc => "Start the services if they are down. Do not restart them if they stop.",
122
- :arity => 2
121
+ desc: "Start the services if they are down. Do not restart them if they stop.",
122
+ arity: 2,
123
123
  },
124
124
  "hup" => {
125
- :desc => "Send the services a HUP.",
126
- :arity => 2
125
+ desc: "Send the services a HUP.",
126
+ arity: 2,
127
127
  },
128
128
  "term" => {
129
- :desc => "Send the services a TERM.",
130
- :arity => 2
129
+ desc: "Send the services a TERM.",
130
+ arity: 2,
131
131
  },
132
132
  "int" => {
133
- :desc => "Send the services an INT.",
134
- :arity => 2
133
+ desc: "Send the services an INT.",
134
+ arity: 2,
135
135
  },
136
136
  "kill" => {
137
- :desc => "Send the services a KILL.",
138
- :arity => 2
137
+ desc: "Send the services a KILL.",
138
+ arity: 2,
139
139
  },
140
140
  "graceful-kill" => {
141
- :desc => "Attempt a graceful stop, then SIGKILL the entire process group.",
142
- :arity => 2
141
+ desc: "Attempt a graceful stop, then SIGKILL the entire process group.",
142
+ arity: 2,
143
143
  },
144
144
  "usr1" => {
145
- :desc => "Send the services a USR1.",
146
- :arity => 2
145
+ desc: "Send the services a USR1.",
146
+ arity: 2,
147
147
  },
148
148
  "usr2" => {
149
- :desc => "Send the services a USR2.",
150
- :arity => 2
151
- }
152
- }
149
+ desc: "Send the services a USR2.",
150
+ arity: 2,
151
+ },
152
+ },
153
153
  }
154
154
  @category_command_map.merge!(service_command_map) if service_commands?
155
155
  end
156
156
 
157
157
  def self.to_method_name(name)
158
- name.gsub(/-/, '_').to_sym
158
+ name.gsub(/-/, "_").to_sym
159
159
  end
160
160
 
161
161
  def to_method_name(name)
@@ -189,7 +189,7 @@ module Omnibus
189
189
  end
190
190
 
191
191
  def load_file(filepath)
192
- eval(IO.read(filepath), nil, filepath, 1)
192
+ eval(IO.read(filepath), nil, filepath, 1) # rubocop: disable Security/Eval
193
193
  end
194
194
 
195
195
  def add_command(name, description, arity = 1, &block)
@@ -220,17 +220,17 @@ module Omnibus
220
220
  end
221
221
 
222
222
  def get_pgrp_from_pid(pid)
223
- ps=`which ps`.chomp
223
+ ps = `which ps`.chomp
224
224
  `#{ps} -p #{pid} -o pgrp=`.chomp
225
225
  end
226
226
 
227
227
  def get_pids_from_pgrp(pgrp)
228
- pgrep=`which pgrep`.chomp
228
+ pgrep = `which pgrep`.chomp
229
229
  `#{pgrep} -g #{pgrp}`.split(/\n/).join(" ")
230
230
  end
231
231
 
232
232
  def sigkill_pgrp(pgrp)
233
- pkill=`which pkill`.chomp
233
+ pkill = `which pkill`.chomp
234
234
  run_command("#{pkill} -9 -g #{pgrp}")
235
235
  end
236
236
 
@@ -251,26 +251,26 @@ module Omnibus
251
251
  def cleanup_procs_and_nuke(filestr, calling_method = nil)
252
252
  run_sv_command("stop")
253
253
 
254
- FileUtils.rm_f("/etc/init/#{name}-runsvdir.conf") if File.exists?("/etc/init/#{name}-runsvdir.conf")
255
- run_command("egrep -v '#{base_path}/embedded/bin/runsvdir-start' /etc/inittab > /etc/inittab.new && mv /etc/inittab.new /etc/inittab") if File.exists?("/etc/inittab")
254
+ FileUtils.rm_f("/etc/init/#{name}-runsvdir.conf") if File.exist?("/etc/init/#{name}-runsvdir.conf")
255
+ run_command("egrep -v '#{base_path}/embedded/bin/runsvdir-start' /etc/inittab > /etc/inittab.new && mv /etc/inittab.new /etc/inittab") if File.exist?("/etc/inittab")
256
256
  run_command("kill -1 1")
257
257
 
258
258
  @backup_dir = Time.now.strftime("/root/#{name}-cleanse-%FT%R")
259
259
 
260
- FileUtils.mkdir_p("/root") unless File.exists?("/root")
260
+ FileUtils.mkdir_p("/root") unless File.exist?("/root")
261
261
  FileUtils.rm_rf(backup_dir)
262
- FileUtils.cp_r(etc_path, backup_dir) if File.exists?(etc_path)
262
+ FileUtils.cp_r(etc_path, backup_dir) if File.exist?(etc_path)
263
263
  run_command("rm -rf #{filestr}")
264
264
  graceful_kill
265
265
 
266
266
  log "Terminating processes running under application users. This will take a few seconds."
267
- run_command("pkill -HUP -u #{kill_users.join(',')}") if kill_users.length > 0
267
+ run_command("pkill -HUP -u #{kill_users.join(",")}") if kill_users.length > 0
268
268
  run_command("pkill -HUP -f 'runsvdir -P #{service_path}'")
269
269
  sleep 3
270
- run_command("pkill -TERM -u #{kill_users.join(',')}") if kill_users.length > 0
270
+ run_command("pkill -TERM -u #{kill_users.join(",")}") if kill_users.length > 0
271
271
  run_command("pkill -TERM -f 'runsvdir -P #{service_path}'")
272
272
  sleep 3
273
- run_command("pkill -KILL -u #{kill_users.join(',')}") if kill_users.length > 0
273
+ run_command("pkill -KILL -u #{kill_users.join(",")}") if kill_users.length > 0
274
274
  run_command("pkill -KILL -f 'runsvdir -P #{service_path}'")
275
275
 
276
276
  get_all_services.each do |die_daemon_die|
@@ -294,13 +294,13 @@ module Omnibus
294
294
  This command will delete *all* local configuration, log, and
295
295
  variable data associated with #{display_name}.
296
296
  EOM
297
- if (with_external)
297
+ if with_external
298
298
  log <<EOM
299
299
  This will also delete externally hosted #{display_name} data.
300
300
  This means that any service you have configured as 'external'
301
301
  will have any #{display_name} permanently deleted.
302
302
  EOM
303
- elsif (not external_services.empty?)
303
+ elsif not external_services.empty?
304
304
  log <<EOM
305
305
 
306
306
  Important note: If you also wish to delete externally hosted #{display_name}
@@ -332,9 +332,8 @@ EOM
332
332
  cleanup_procs_and_nuke("#{service_path}/* /tmp/opt #{data_path} #{etc_path} #{log_path}", "cleanse")
333
333
  end
334
334
 
335
-
336
335
  def get_all_services_files
337
- Dir[File.join(sv_path, '*')]
336
+ Dir[File.join(sv_path, "*")]
338
337
  end
339
338
 
340
339
  def get_all_services
@@ -345,7 +344,7 @@ EOM
345
344
  File.symlink?("#{service_path}/#{service_name}")
346
345
  end
347
346
 
348
- def run_sv_command(sv_cmd, service=nil)
347
+ def run_sv_command(sv_cmd, service = nil)
349
348
  exit_status = 0
350
349
  sv_cmd = "1" if sv_cmd == "usr1"
351
350
  sv_cmd = "2" if sv_cmd == "usr2"
@@ -398,7 +397,7 @@ EOM
398
397
  end
399
398
 
400
399
  # All other services respond normally to p-c-c * commands
401
- return true
400
+ true
402
401
  end
403
402
 
404
403
  # removed services are configured via the attributes file in
@@ -430,7 +429,8 @@ EOM
430
429
  # 'opscode', not 'private-chef'
431
430
  def package_name
432
431
  case @name
433
- when "opscode"
432
+ # The "opscode" in /opt/opscode
433
+ when ::ChefUtils::Dist::Org::LEGACY_CONF_DIR
434
434
  "private-chef"
435
435
  else
436
436
  @name
@@ -439,24 +439,24 @@ EOM
439
439
 
440
440
  # returns nil when chef-server-running.json does not exist
441
441
  def running_config
442
- @running_config ||= begin
443
- if File.exists?("#{etc_path}/chef-server-running.json")
444
- JSON.parse(File.read("#{etc_path}/chef-server-running.json"))
445
- end
446
- end
442
+ fname = "#{etc_path}/#{::ChefUtils::Dist::Server::SERVER}-running.json"
443
+ @running_config ||= if File.exist?(fname)
444
+ JSON.parse(File.read(fname))
445
+ end
447
446
  end
448
447
 
449
448
  # Helper function that returns the hash of config hashes that have the key 'external' : true
450
449
  # in the running config. If none exist it will return an empty hash.
451
450
  def external_services
452
- @external_services ||= running_package_config.select { |k, v| v.class == Hash and v["external"] == true }
451
+ @external_services ||= running_package_config.select { |k, v| v.class == Hash and v["external"] == true }
453
452
  end
454
453
 
455
454
  # Helper function that returns true if an external service entry exists for
456
455
  # the named service
457
456
  def service_external?(service)
458
457
  return false if service.nil?
459
- return external_services.has_key? service
458
+
459
+ external_services.key? service
460
460
  end
461
461
 
462
462
  # Gives package config from the running_config.
@@ -464,7 +464,7 @@ EOM
464
464
  # reference a valid key, this will return an empty hash
465
465
  def running_package_config
466
466
  if (cfg = running_config)
467
- cfg[package_name.gsub(/-/, '_')] || {}
467
+ cfg[package_name.gsub(/-/, "_")] || {}
468
468
  else
469
469
  {}
470
470
  end
@@ -481,13 +481,13 @@ EOM
481
481
  def remove_old_node_state
482
482
  node_cache_path = "#{base_path}/embedded/nodes/"
483
483
  status = run_command("rm -rf #{node_cache_path}")
484
- if !status.success?
484
+ unless status.success?
485
485
  log "Could not remove cached node state!"
486
486
  exit 1
487
487
  end
488
488
  end
489
489
 
490
- def run_chef(attr_location, args='')
490
+ def run_chef(attr_location, args = "")
491
491
  if @verbose
492
492
  log_level = "-l debug"
493
493
  elsif @quiet
@@ -530,7 +530,7 @@ EOM
530
530
  # any license to accept.
531
531
  return unless File.exist?(project_license_path)
532
532
 
533
- if !File.exist?(license_guard_file_path)
533
+ unless File.exist?(license_guard_file_path)
534
534
  if override_accept || ask_license_acceptance
535
535
  FileUtils.mkdir_p(data_path)
536
536
  FileUtils.touch(license_guard_file_path)
@@ -544,7 +544,7 @@ EOM
544
544
  def ask_license_acceptance
545
545
  log "To use this software, you must agree to the terms of the software license agreement."
546
546
 
547
- if !STDIN.tty?
547
+ unless STDIN.tty?
548
548
  log "Please view and accept the software license agreement, or pass --accept-license."
549
549
  exit(1)
550
550
  end
@@ -578,8 +578,8 @@ EOM
578
578
  # find /var/log -type f -not -path '*/sasl/*' | grep -E -v '(lock|@|tgz|gzip)' | xargs tail --follow=name --retry
579
579
  command = "find -L #{log_path}"
580
580
  command << "/#{args[1]}" if args[1]
581
- command << ' -type f'
582
- command << log_path_exclude.map { |path| " -not -path '#{path}'" }.join(' ')
581
+ command << " -type f"
582
+ command << log_path_exclude.map { |path| " -not -path '#{path}'" }.join(" ")
583
583
  command << " | grep -E -v '#{log_exclude}' | xargs tail --follow=name --retry"
584
584
 
585
585
  system(command)
@@ -594,16 +594,17 @@ EOM
594
594
  exit_status = 0
595
595
  get_all_services.each do |service_name|
596
596
  next if !service.nil? && service_name != service
597
+
597
598
  if service_enabled?(service_name)
598
- pidfile="#{sv_path}/#{service_name}/supervise/pid"
599
- pid=File.read(pidfile).chomp if File.exists?(pidfile)
599
+ pidfile = "#{sv_path}/#{service_name}/supervise/pid"
600
+ pid = File.read(pidfile).chomp if File.exist?(pidfile)
600
601
  if pid.nil? || !is_integer?(pid)
601
602
  log "could not find #{service_name} runit pidfile (service already stopped?), cannot attempt SIGKILL..."
602
603
  status = run_command("#{base_path}/init/#{service_name} stop")
603
604
  exit_status = status.exitstatus if exit_status == 0 && !status.success?
604
605
  next
605
606
  end
606
- pgrp=get_pgrp_from_pid(pid)
607
+ pgrp = get_pgrp_from_pid(pid)
607
608
  if pgrp.nil? || !is_integer?(pgrp)
608
609
  log "could not find pgrp of pid #{pid} (not running?), cannot attempt SIGKILL..."
609
610
  status = run_command("#{base_path}/init/#{service_name} stop")
@@ -611,14 +612,14 @@ EOM
611
612
  next
612
613
  end
613
614
  run_command("#{base_path}/init/#{service_name} stop")
614
- pids=get_pids_from_pgrp(pgrp)
615
- if !pids.empty?
615
+ pids = get_pids_from_pgrp(pgrp)
616
+ unless pids.empty?
616
617
  log "found stuck pids still running in process group: #{pids}, sending SIGKILL" unless pids.empty?
617
618
  sigkill_pgrp(pgrp)
618
619
  end
619
620
  else
620
621
  log "#{service_name} disabled, not stopping"
621
- exit_status =1
622
+ exit_status = 1
622
623
  end
623
624
  end
624
625
  exit! exit_status
@@ -632,7 +633,7 @@ EOM
632
633
  end
633
634
  category_command_map.each do |category, commands|
634
635
  # Remove "-" and replace with spaces in category and capalize for output
635
- category_string = category.gsub("-", " ").split.map(&:capitalize).join(' ')
636
+ category_string = category.gsub("-", " ").split.map(&:capitalize).join(" ")
636
637
  log "#{category_string} Commands:\n"
637
638
 
638
639
  # Print each command in this category
@@ -663,19 +664,19 @@ EOM
663
664
 
664
665
  # If it begins with a '-', it is an option.
665
666
  def is_option?(arg)
666
- arg && arg[0] == '-'
667
+ arg && arg[0] == "-"
667
668
  end
668
669
 
669
670
  # retrieves the commmand from either the command_map
670
671
  # or the category_command_map, if the command is not found
671
672
  # return nil
672
673
  def retrieve_command(command_to_run)
673
- if command_map.has_key?(command_to_run)
674
+ if command_map.key?(command_to_run)
674
675
  command_map[command_to_run]
675
676
  else
676
677
  command = nil
677
678
  category_command_map.each do |category, commands|
678
- command = commands[command_to_run] if commands.has_key?(command_to_run)
679
+ command = commands[command_to_run] if commands.key?(command_to_run)
679
680
  end
680
681
  # return the command, or nil if it wasn't found
681
682
  command
@@ -689,8 +690,8 @@ EOM
689
690
  def run(args)
690
691
  # Ensure Omnibus related binaries are in the PATH
691
692
  ENV["PATH"] = [File.join(base_path, "bin"),
692
- File.join(base_path, "embedded","bin"),
693
- ENV['PATH']].join(":")
693
+ File.join(base_path, "embedded", "bin"),
694
+ ENV["PATH"]].join(":")
694
695
 
695
696
  command_to_run = args[0]
696
697
 
@@ -765,12 +766,12 @@ EOM
765
766
 
766
767
  def run_global_pre_hooks
767
768
  @global_pre_hooks.each do |hook_name, method_name|
768
- begin
769
- send(method_name)
770
- rescue => e
771
- $stderr.puts("Global pre-hook '#{hook_name}' failed with: '#{e.message}'")
772
- exit(1)
773
- end
769
+
770
+ send(method_name)
771
+ rescue => e
772
+ $stderr.puts("Global pre-hook '#{hook_name}' failed with: '#{e.message}'")
773
+ exit(1)
774
+
774
775
  end
775
776
  end
776
777
 
@@ -791,10 +792,11 @@ EOM
791
792
  send(method, *args)
792
793
  else
793
794
  return true if args.empty?
795
+
794
796
  if SV_COMMAND_NAMES.include? command
795
797
  if service_external? args[0]
796
798
  log error_external_service(command, args[0])
797
- return false;
799
+ return false
798
800
  end
799
801
  end
800
802
  true
@@ -819,6 +821,7 @@ EOM
819
821
  log_internal_service_header if service.nil?
820
822
  true
821
823
  end
824
+
822
825
  # Status gets its own hook because each externalized service will
823
826
  # have its own things to do in order to report status.
824
827
  # As above, we may also include an output header to show that we're
@@ -869,22 +872,22 @@ EOM
869
872
  # Add some output headers if we have external services enabled
870
873
  def service_list_pre_hook
871
874
  log_internal_service_header
872
- return true
875
+ true
873
876
  end
874
877
 
875
878
  # Capture external services in the output list as well.
876
879
  def service_list_post_hook
877
880
  log_external_service_header
878
881
  external_services.each do |name, settings|
879
- log " > #{name} on #{settings['vip']}"
882
+ log " > #{name} on #{settings["vip"]}"
880
883
  end
881
884
  end
882
885
 
883
886
  def error_external_service(command, service)
884
- <<EOM
887
+ <<EOM
885
888
  -------------------------------------------------------------------
886
889
  The service #{service} is running externally and cannot be managed
887
- vi chef-server-ctl. Please log into #{external_services[service]['vip'] }
890
+ vi chef-server-ctl. Please log into #{external_services[service]["vip"]}
888
891
  to manage it directly.
889
892
  -------------------------------------------------------------------
890
893
  EOM
@@ -894,8 +897,8 @@ EOM
894
897
  if message.class == String
895
898
  message = message.split("\n")
896
899
  end
897
- spaces = " "*indent
898
- message.map!{|line| "#{spaces}#{line.strip}"}
900
+ spaces = " " * indent
901
+ message.map! { |line| "#{spaces}#{line.strip}" }
899
902
  message.join("\n")
900
903
  end
901
904
 
@@ -903,6 +906,7 @@ EOM
903
906
  # Don't decorate output unless we have
904
907
  # external services to report on.
905
908
  return if external_services.empty?
909
+
906
910
  log "-------------------"
907
911
  log " Internal Services "
908
912
  log "-------------------"
@@ -910,6 +914,7 @@ EOM
910
914
 
911
915
  def log_external_service_header
912
916
  return if external_services.empty?
917
+
913
918
  log "-------------------"
914
919
  log " External Services "
915
920
  log "-------------------"
metadata CHANGED
@@ -1,15 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omnibus-ctl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.6.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chef Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-08 00:00:00.000000000 Z
11
+ date: 2022-02-15 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: chef-utils
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 16.5.54
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 16.5.54
27
+ - !ruby/object:Gem::Dependency
28
+ name: chefstyle
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.2.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.2.0
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: rake
15
43
  requirement: !ruby/object:Gem::Requirement
@@ -61,7 +89,7 @@ executables:
61
89
  extensions: []
62
90
  extra_rdoc_files: []
63
91
  files:
64
- - README.md
92
+ - LICENSE
65
93
  - bin/omnibus-ctl
66
94
  - lib/omnibus-ctl.rb
67
95
  - lib/omnibus-ctl/version.rb
@@ -77,15 +105,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
77
105
  requirements:
78
106
  - - ">="
79
107
  - !ruby/object:Gem::Version
80
- version: '0'
108
+ version: '2.6'
81
109
  required_rubygems_version: !ruby/object:Gem::Requirement
82
110
  requirements:
83
111
  - - ">="
84
112
  - !ruby/object:Gem::Version
85
113
  version: '0'
86
114
  requirements: []
87
- rubyforge_project:
88
- rubygems_version: 2.6.13
115
+ rubygems_version: 3.1.4
89
116
  signing_key:
90
117
  specification_version: 4
91
118
  summary: Provides command line control for omnibus packages
data/README.md DELETED
@@ -1,121 +0,0 @@
1
- # omnibus-ctl
2
-
3
- [![Build Status Master](https://travis-ci.org/chef/omnibus-ctl.svg?branch=master)](https://travis-ci.org/chef/omnibus-ctl)
4
-
5
- omnibus-ctl provides service control and configuration for omnibus packages.
6
-
7
- For an introduction, please see this blog post [Omnibus-ctl: What is it and what can it do for you?](https://www.chef.io/blog/2015/05/26/omnibus-ctl-what-is-it-and-what-can-it-do-for-you/).
8
-
9
- ## Run the Tests!
10
-
11
- There are tests in this repo that should be run before merging to master in the `spec` directory.
12
-
13
- To run them, first install rspec via bundler:
14
-
15
- ```
16
- bundle install
17
- ```
18
-
19
- Then run the tests:
20
-
21
- ```
22
- bin/rspec
23
- ```
24
-
25
- ## Command API
26
-
27
- There are two main functions you will use in your `*-ctl` project to add commands.
28
-
29
- ### add_command_under_category(string, string, string, int, ruby_block)
30
-
31
- This method will add a new command to your ctl under a category, useful for grouping similar commands together logically in help output.
32
-
33
- Input arguments:
34
-
35
- 1. Name of the command.
36
- 2. Category of the command. It should be string consisting of only characters and "-". If the category does not exist, it will be added. Default categories are "general" and "service-management" (if the latter is enabled).
37
- 3. Description. This will be outputted below the command name when the help command is run.
38
- 4. Arity. TODO: Due to current bug, this must be 2, I believe. We should fix this.
39
- 5. Ruby block. Ruby code to be executed when your command is run (arguments to that command will be passed into the block).
40
-
41
- ### add_command(string, string, int, ruby_block)
42
-
43
- This method will add a new command to your ctl without a category. It will be displayed above all categories when the help command is called.
44
-
45
- Input arguments are the same as `add_command_under_category` except 2 doesn't exist.
46
-
47
- ### Sample Output
48
-
49
- ```
50
- # sample-ctl help
51
- /opt/opscode/embedded/bin/sample-ctl: command (subcommand)
52
- command-without-category
53
- Here is an insightful description for the above command, added via add_command.
54
- another-command-without-category
55
- Yet another description.
56
- Some Category Of Commands:
57
- command-with-category
58
- Exciting description of command added via add_command_under_category.
59
- better-command-with-category
60
- You get the idea.
61
- Another Category:
62
- command-with-better-category
63
- I'm not just going to copy-pasta above example descriptions.
64
- better-command-with-better-category
65
- I'm running out of ideas.
66
- ```
67
-
68
- If you only use `add_command_under_category` to add your custom commands, everything will be outputted under a category.
69
-
70
- ## Pre-hook API
71
-
72
- ### add_global_pre_hook(string, ruby_block)
73
-
74
- This method will add a global pre-hook block that will be executed before any
75
- *-ctl command is run. If the pre-hook raises an exception it will cause an early
76
- exit before the command is run.
77
-
78
- Input Arguments:
79
-
80
- 1. Name of the hook
81
- 1. Ruby block of the code to be executed.
82
-
83
- ### Sample
84
-
85
- ```ruby
86
- add_global_pre_hook "ensure that the user is always root" do
87
- raise "You must run this command as root" unless Process.uid == 0
88
- end
89
- ```
90
-
91
- ## Releasing
92
-
93
- *NOTE: Versions prior to 0.3.6 do not use a "v" prefix for their tags. Current
94
- versions do.*
95
-
96
- * Update the version in lib/omnibus-ctl/version.rb.
97
- * Update the [Change log](CHANGELOG.md).
98
- * Commit those changes.
99
- * Make sure you are an owner of the
100
- [omnibus-ctl gem on RubyGems.org](https://rubygems.org/gems/omnibus-ctl). If
101
- you aren't, contact one of the owners to be added.
102
- * `rake release`. This will tag the version, push it to GitHub and RubyGems.
103
-
104
- ## License
105
-
106
- See the LICENSE file for details.
107
-
108
- Copyright: Copyright (c) 2012-2015 Chef Software, Inc.
109
- License: Apache License, Version 2.0
110
-
111
- Licensed under the Apache License, Version 2.0 (the "License");
112
- you may not use this file except in compliance with the License.
113
- You may obtain a copy of the License at
114
-
115
- http://www.apache.org/licenses/LICENSE-2.0
116
-
117
- Unless required by applicable law or agreed to in writing, software
118
- distributed under the License is distributed on an "AS IS" BASIS,
119
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120
- See the License for the specific language governing permissions and
121
- limitations under the License.