vanagon 0.17.0 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/bin/build +3 -1
  4. data/bin/build_host_info +3 -1
  5. data/bin/build_requirements +3 -1
  6. data/bin/inspect +3 -1
  7. data/bin/render +3 -1
  8. data/bin/repo +3 -1
  9. data/bin/ship +3 -1
  10. data/bin/sign +3 -1
  11. data/extras/completions/vanagon.bash +38 -0
  12. data/extras/completions/vanagon.zsh +41 -0
  13. data/lib/vanagon/cli.rb +12 -2
  14. data/lib/vanagon/cli/build.rb +12 -3
  15. data/lib/vanagon/cli/build_host_info.rb +12 -3
  16. data/lib/vanagon/cli/build_requirements.rb +13 -5
  17. data/lib/vanagon/cli/completion.rb +44 -0
  18. data/lib/vanagon/cli/inspect.rb +12 -3
  19. data/lib/vanagon/cli/list.rb +74 -0
  20. data/lib/vanagon/cli/render.rb +11 -2
  21. data/lib/vanagon/cli/ship.rb +5 -4
  22. data/lib/vanagon/cli/sign.rb +3 -2
  23. data/lib/vanagon/component.rb +13 -10
  24. data/lib/vanagon/component/dsl.rb +27 -20
  25. data/lib/vanagon/component/source.rb +2 -1
  26. data/lib/vanagon/component/source/git.rb +35 -10
  27. data/lib/vanagon/component/source/http.rb +3 -2
  28. data/lib/vanagon/component/source/local.rb +2 -1
  29. data/lib/vanagon/component/source/rewrite.rb +3 -2
  30. data/lib/vanagon/driver.rb +35 -34
  31. data/lib/vanagon/engine/always_be_scheduling.rb +12 -11
  32. data/lib/vanagon/engine/docker.rb +2 -1
  33. data/lib/vanagon/engine/ec2.rb +5 -4
  34. data/lib/vanagon/engine/hardware.rb +4 -3
  35. data/lib/vanagon/engine/pooler.rb +6 -5
  36. data/lib/vanagon/environment.rb +3 -2
  37. data/lib/vanagon/logger.rb +31 -0
  38. data/lib/vanagon/platform.rb +38 -5
  39. data/lib/vanagon/platform/deb.rb +2 -0
  40. data/lib/vanagon/platform/dsl.rb +23 -6
  41. data/lib/vanagon/platform/windows.rb +3 -1
  42. data/lib/vanagon/project.rb +25 -15
  43. data/lib/vanagon/project/dsl.rb +6 -5
  44. data/lib/vanagon/utilities.rb +5 -4
  45. data/resources/deb/control.erb +1 -1
  46. data/resources/deb/postinst.erb +24 -13
  47. data/resources/deb/postrm.erb +9 -6
  48. data/resources/deb/prerm.erb +18 -8
  49. data/resources/osx/postinstall.erb +5 -1
  50. data/resources/rpm/project.spec.erb +12 -12
  51. data/resources/solaris/10/depend.erb +2 -2
  52. data/resources/solaris/10/postinstall.erb +10 -2
  53. data/resources/solaris/11/p5m.erb +2 -2
  54. data/spec/lib/vanagon/cli_spec.rb +143 -0
  55. data/spec/lib/vanagon/component/dsl_spec.rb +54 -10
  56. data/spec/lib/vanagon/component/source/git_spec.rb +4 -4
  57. data/spec/lib/vanagon/component_spec.rb +15 -2
  58. data/spec/lib/vanagon/driver_spec.rb +1 -1
  59. data/spec/lib/vanagon/engine/always_be_scheduling_spec.rb +4 -4
  60. data/spec/lib/vanagon/platform_spec.rb +80 -0
  61. data/spec/lib/vanagon/utilities_spec.rb +4 -1
  62. metadata +37 -32
@@ -1,6 +1,7 @@
1
1
  require 'vanagon/environment'
2
2
  require 'vanagon/platform/dsl'
3
3
  require 'vanagon/utilities'
4
+ require 'vanagon/logger'
4
5
 
5
6
  class Vanagon
6
7
  class Platform
@@ -32,6 +33,9 @@ class Vanagon
32
33
  # Where does a given platform expect to find init scripts/service files?
33
34
  # e.g. /etc/init.d, /usr/lib/systemd/system
34
35
  attr_accessor :servicedir
36
+ # Array of OpenStructs containing the servicetype and the corresponding
37
+ # servicedir
38
+ attr_accessor :servicetypes
35
39
  # Where does a given platform's init system expect to find
36
40
  # something resembling 'defaults' files. Most likely to apply
37
41
  # to Linux systems that use SysV-ish, upstart, or systemd init systems.
@@ -152,9 +156,9 @@ class Vanagon
152
156
  dsl.instance_eval(File.read(platfile), platfile, 1)
153
157
  dsl._platform
154
158
  rescue StandardError => e
155
- warn "Error loading platform '#{name}' using '#{platfile}':"
156
- warn e
157
- warn e.backtrace.join("\n")
159
+ VanagonLogger.error "Error loading platform '#{name}' using '#{platfile}':"
160
+ VanagonLogger.error(e)
161
+ VanagonLogger.error e.backtrace.join("\n")
158
162
  raise e
159
163
  end
160
164
 
@@ -244,6 +248,7 @@ class Vanagon
244
248
  # Our first attempt at defining metadata about a platform
245
249
  @cross_compiled ||= false
246
250
  @valid_operators ||= ['<', '>', '<=', '>=', '=']
251
+ @servicetypes = []
247
252
  end
248
253
 
249
254
  def shell # rubocop:disable Lint/DuplicateMethods
@@ -401,7 +406,7 @@ class Vanagon
401
406
  # @deprecated Please use is_macos? instead
402
407
  # @return [true, false] true if it is an osx variety, false otherwise
403
408
  def is_osx?
404
- warn "is_osx? is a deprecated method, please use #is_macos? instead."
409
+ VanagonLogger.info "is_osx? is a deprecated method, please use #is_macos? instead."
405
410
  is_macos?
406
411
  end
407
412
 
@@ -539,7 +544,7 @@ class Vanagon
539
544
  match = version_string.match(VERSION_REGEX)
540
545
 
541
546
  if match.nil?
542
- warn "Passing a version without an operator is deprecated!"
547
+ VanagonLogger.info "Passing a version without an operator is deprecated!"
543
548
  operator = default
544
549
  version = version_string
545
550
  end
@@ -552,5 +557,33 @@ class Vanagon
552
557
  def validate_operator(operator_string)
553
558
  valid_operators.include?(operator_string)
554
559
  end
560
+
561
+ # Get all configured service types (added through plat.servicetype)
562
+ # @return array of service types, empty array if none have been configured
563
+ def get_service_types
564
+ if @servicetypes.any?
565
+ @servicetypes.flat_map(&:servicetype).compact
566
+ elsif @servicetype
567
+ [@servicetype]
568
+ else
569
+ []
570
+ end
571
+ end
572
+
573
+ # Get configured service dir (added through plat.servicedir, or plat.servicetype 'foo', servicedir: 'bar')
574
+ # @param servicetype the service type you want the service dir for (optional)
575
+ # @raises VanagonError if more than one service dir is found
576
+ def get_service_dir(servicetype = '')
577
+ if @servicetypes.empty?
578
+ return @servicedir
579
+ end
580
+ servicedir = @servicetypes.select { |s| s.servicetype.include?(servicetype) }.flat_map(&:servicedir).compact
581
+
582
+ if servicedir.size > 1
583
+ raise Vanagon::Error, "You can only have one service dir for each service type. Found '#{servicedir.join(',')}' for service type #{servicetype}"
584
+ end
585
+
586
+ servicedir.first
587
+ end
555
588
  end
556
589
  end
@@ -13,6 +13,8 @@ class Vanagon
13
13
  copy_extensions = '*.deb'
14
14
  end
15
15
  pkg_arch_opt = project.noarch ? "" : "-a#{@architecture}"
16
+ pkg_arch_opt = '-aarm64' if pkg_arch_opt == '-aaarch64'
17
+
16
18
  ["mkdir -p output/#{target_dir}",
17
19
  "mkdir -p $(tempdir)/#{project.name}-#{project.version}",
18
20
  "cp #{project.name}-#{project.version}.tar.gz $(tempdir)/#{project.name}_#{project.version}.orig.tar.gz",
@@ -8,7 +8,9 @@ require 'vanagon/platform/osx'
8
8
  require 'vanagon/platform/solaris_10'
9
9
  require 'vanagon/platform/solaris_11'
10
10
  require 'vanagon/platform/windows'
11
+ require 'vanagon/logger'
11
12
  require 'securerandom'
13
+ require 'ostruct'
12
14
  require 'uri'
13
15
 
14
16
  class Vanagon
@@ -218,6 +220,11 @@ class Vanagon
218
220
  # @param dir [String] Directory where service files live on the platform
219
221
  def servicedir(dir)
220
222
  @platform.servicedir = dir
223
+
224
+ # Add to the servicetypes array if we haven't already
225
+ if @platform.servicetype && @platform.servicedir && @platform.servicetypes.select { |s| s.servicetype == @platform.servicetype }.empty?
226
+ @platform.servicetypes << OpenStruct.new(:servicetype => @platform.servicetype, :servicedir => @platform.servicedir)
227
+ end
221
228
  end
222
229
 
223
230
  # Set the directory where default or sysconfig files live for the platform
@@ -230,8 +237,18 @@ class Vanagon
230
237
  # Set the servicetype for the platform so that services can be installed correctly.
231
238
  #
232
239
  # @param type [String] service type for the platform ('sysv' for example)
233
- def servicetype(type)
234
- @platform.servicetype = type
240
+ # @param servicedir [String] service dir for this platform and service type ('/etc/init.d' for example). Optional.
241
+ def servicetype(type, servicedir: nil) # rubocop:disable Metrics/AbcSize
242
+ if servicedir
243
+ @platform.servicetypes << OpenStruct.new(:servicetype => type, :servicedir => servicedir)
244
+ else
245
+ @platform.servicetype = type
246
+ end
247
+
248
+ # Add to the servicetypes array if we haven't already
249
+ if @platform.servicetype && @platform.servicedir && @platform.servicetypes.select { |s| s.servicetype == @platform.servicetype }.empty?
250
+ @platform.servicetypes << OpenStruct.new(:servicetype => @platform.servicetype, :servicedir => @platform.servicedir)
251
+ end
235
252
  end
236
253
 
237
254
  # Set the list of possible host to perform a build on (when not using
@@ -259,7 +276,7 @@ class Vanagon
259
276
  # @param name [String] name that the pooler uses for this platform
260
277
  # @deprecated Please use vmpooler_template instead, this will be removed in a future vanagon release.
261
278
  def vcloud_name(cloud_name)
262
- warn "vcloud_name is a deprecated platform DSL method, and will be removed in a future vanagon release. Please use vmpooler_template instead."
279
+ VanagonLogger.info "vcloud_name is a deprecated platform DSL method, and will be removed in a future vanagon release. Please use vmpooler_template instead."
263
280
  self.vmpooler_template(cloud_name)
264
281
  end
265
282
 
@@ -394,7 +411,7 @@ class Vanagon
394
411
  # @param gpg_key [String] optional gpg key to be fetched via curl and installed
395
412
  # @deprecated Please use the add_build_repository DSL method instead. apt_repo will be removed in a future vanagon release.
396
413
  def apt_repo(definition, gpg_key = nil)
397
- warn "Please use the add_build_repository DSL method instead. apt_repo will be removed in a future vanagon release."
414
+ VanagonLogger.info "Please use the add_build_repository DSL method instead. apt_repo will be removed in a future vanagon release."
398
415
  self.add_build_repository(definition, gpg_key)
399
416
  end
400
417
 
@@ -403,7 +420,7 @@ class Vanagon
403
420
  # @param definition [String] the repo setup URI or RPM file
404
421
  # @deprecated Please use the add_build_repository DSL method instead. yum_repo will be removed in a future vanagon release.
405
422
  def yum_repo(definition)
406
- warn "Please use the add_build_repository DSL method instead. yum_repo will be removed in a future vanagon release."
423
+ VanagonLogger.info "Please use the add_build_repository DSL method instead. yum_repo will be removed in a future vanagon release."
407
424
  self.add_build_repository(definition)
408
425
  end
409
426
 
@@ -412,7 +429,7 @@ class Vanagon
412
429
  # @param definition [String] the repo setup URI or RPM file
413
430
  # @deprecated Please use the add_build_repository DSL method instead. zypper_repo will be removed in a future vanagon release.
414
431
  def zypper_repo(definition)
415
- warn "Please use the add_build_repository DSL method instead. zypper_repo will be removed in a future vanagon release."
432
+ VanagonLogger.info "Please use the add_build_repository DSL method instead. zypper_repo will be removed in a future vanagon release."
416
433
  self.add_build_repository(definition)
417
434
  end
418
435
 
@@ -1,3 +1,5 @@
1
+ require 'vanagon/logger'
2
+
1
3
  class Vanagon
2
4
  class Platform
3
5
  class Windows < Vanagon::Platform
@@ -231,7 +233,7 @@ class Vanagon
231
233
  ]
232
234
  end
233
235
  rescue RuntimeError
234
- warn "Unable to connect to #{project.signing_username}@#{project.signing_hostname}, skipping signing extra files: #{project.extra_files_to_sign.join(',')}"
236
+ VanagonLogger.error "Unable to connect to #{project.signing_username}@#{project.signing_hostname}, skipping signing extra files: #{project.extra_files_to_sign.join(',')}"
235
237
  end
236
238
  end
237
239
  make_commands << [
@@ -1,5 +1,6 @@
1
1
  require 'vanagon/component'
2
2
  require 'vanagon/environment'
3
+ require 'vanagon/logger'
3
4
  require 'vanagon/platform'
4
5
  require 'vanagon/project/dsl'
5
6
  require 'vanagon/utilities'
@@ -130,9 +131,9 @@ class Vanagon
130
131
  dsl.instance_eval(File.read(projfile), projfile, 1)
131
132
  dsl._project
132
133
  rescue StandardError => e
133
- warn "Error loading project '#{name}' using '#{projfile}':"
134
- warn e
135
- warn e.backtrace.join("\n")
134
+ VanagonLogger.error "Error loading project '#{name}' using '#{projfile}':"
135
+ VanagonLogger.error(e)
136
+ VanagonLogger.error e.backtrace.join("\n")
136
137
  raise e
137
138
  end
138
139
 
@@ -296,10 +297,14 @@ class Vanagon
296
297
  #
297
298
  # @return [Array] array of runtime requirements for the project
298
299
  def get_requires
299
- req = []
300
- req << components.flat_map(&:requires)
301
- req << @requires
302
- req.flatten.uniq
300
+ requires = []
301
+ requires << @requires.flatten
302
+ requires << components.flat_map(&:requires)
303
+ requires.flatten!
304
+ requires.each do |requirement|
305
+ requirement.version = @platform.version_munger(requirement.version, default: '<') if requirement.version
306
+ end
307
+ requires.uniq
303
308
  end
304
309
 
305
310
  # Collects all of the replacements for the project and its components
@@ -307,8 +312,8 @@ class Vanagon
307
312
  # @return [Array] array of package level replacements for the project
308
313
  def get_replaces
309
314
  replaces = []
310
- replaces.push @replaces.flatten
311
- replaces.push components.flat_map(&:replaces)
315
+ replaces << @replaces.flatten
316
+ replaces << components.flat_map(&:replaces)
312
317
  replaces.flatten!
313
318
  replaces.each do |replace|
314
319
  # TODO: Make this a more reasonable default before 1.0.0
@@ -324,8 +329,9 @@ class Vanagon
324
329
 
325
330
  # Collects all of the conflicts for the project and its components
326
331
  def get_conflicts
327
- conflicts = components.flat_map(&:conflicts) + @conflicts
328
- # Mash the whole thing down into a flat Array
332
+ conflicts = []
333
+ conflicts << @conflicts.flatten
334
+ conflicts << components.flat_map(&:conflicts)
329
335
  conflicts.flatten!
330
336
  conflicts.each do |conflict|
331
337
  # TODO: Make this a more reasonable default before 1.0.0
@@ -345,10 +351,14 @@ class Vanagon
345
351
  # will return nil
346
352
  #
347
353
  # @param [string] name of service to grab
348
- # @return [@component.service obj] specific service
354
+ # @return [@component.service obj] specific service, or array of services
355
+ # if there's more than one
349
356
  def get_service(name)
350
357
  components.each do |component|
351
358
  if component.name == name
359
+ if component.service.size == 1
360
+ return component.service.first
361
+ end
352
362
  return component.service
353
363
  end
354
364
  end
@@ -360,8 +370,8 @@ class Vanagon
360
370
  # @return [Array] array of package level provides for the project
361
371
  def get_provides
362
372
  provides = []
363
- provides.push @provides.flatten
364
- provides.push components.flat_map(&:provides)
373
+ provides << @provides.flatten
374
+ provides << components.flat_map(&:provides)
365
375
  provides.flatten!
366
376
  provides.each do |provide|
367
377
  # TODO: Make this a more reasonable default before 1.0.0
@@ -841,7 +851,7 @@ class Vanagon
841
851
  end
842
852
 
843
853
  def load_upstream_metadata(metadata_uri)
844
- warn "Loading metadata from #{metadata_uri}"
854
+ VanagonLogger.info "Loading metadata from #{metadata_uri}"
845
855
  case metadata_uri
846
856
  when /^http/
847
857
  @upstream_metadata = JSON.parse(Net::HTTP.get(URI(metadata_uri)))
@@ -1,4 +1,5 @@
1
1
  require 'vanagon/errors'
2
+ require 'vanagon/logger'
2
3
  require 'vanagon/project'
3
4
  require 'vanagon/utilities'
4
5
  require 'vanagon/component/source'
@@ -109,8 +110,8 @@ class Vanagon
109
110
  # Sets the run time requirements for the project. Mainly for use in packaging.
110
111
  #
111
112
  # @param req [String] of requirements of the project
112
- def requires(req)
113
- @project.requires << req
113
+ def requires(requirement, version = nil)
114
+ @project.requires << OpenStruct.new(:requirement => requirement, :version => version)
114
115
  end
115
116
 
116
117
  # Indicates that this component replaces a system level package. Replaces can be collected and used by the project and package.
@@ -185,7 +186,7 @@ class Vanagon
185
186
  last_tag = repo_object.describe('HEAD', { :abbrev => 0 })
186
187
  release(repo_object.rev_list("#{last_tag}..HEAD", { :count => true }))
187
188
  rescue Git::GitExecuteError
188
- warn "Directory '#{File.expand_path('..', @configdir)}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
189
+ VanagonLogger.error "Directory '#{File.expand_path('..', @configdir)}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
189
190
  end
190
191
 
191
192
  # Sets the version for the project based on a git describe of the
@@ -196,7 +197,7 @@ class Vanagon
196
197
  git_version = Git.open(File.expand_path("..", @configdir)).describe('HEAD', tags: true)
197
198
  version(git_version.split('-').reject(&:empty?).join('.'))
198
199
  rescue Git::GitExecuteError
199
- warn "Directory '#{File.expand_path('..', @configdir)}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
200
+ VanagonLogger.error "Directory '#{File.expand_path('..', @configdir)}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
200
201
  end
201
202
 
202
203
  # Get the version string from a git branch name. This will look for a '.'
@@ -268,7 +269,7 @@ class Vanagon
268
269
  #
269
270
  # @param name [String] name of component to add. must be present in configdir/components and named $name.rb currently
270
271
  def component(name)
271
- warn "Loading #{name}" if @project.settings[:verbose]
272
+ VanagonLogger.info "Loading #{name}" if @project.settings[:verbose]
272
273
  if @include_components.empty? or @include_components.include?(name)
273
274
  component = Vanagon::Component.load_component(name, File.join(@configdir, "components"), @project.settings, @project.platform)
274
275
  @project.components << component
@@ -9,6 +9,7 @@ require 'timeout'
9
9
  # but it provides a wealth of useful constants
10
10
  require 'English'
11
11
  require 'vanagon/extensions/string'
12
+ require 'vanagon/logger'
12
13
 
13
14
  class Vanagon
14
15
  module Utilities
@@ -165,7 +166,7 @@ class Vanagon
165
166
  yield
166
167
  return true
167
168
  rescue StandardError => e
168
- warn 'An error was encountered evaluating block. Retrying..'
169
+ VanagonLogger.error 'An error was encountered evaluating block. Retrying..'
169
170
  error = e
170
171
  end
171
172
  end
@@ -238,7 +239,7 @@ class Vanagon
238
239
  # output of the command if return_command_output is true
239
240
  # @raise [RuntimeError] If there is no target given or the command fails an exception is raised
240
241
  def remote_ssh_command(target, command, port = 22, return_command_output: false)
241
- warn "Executing '#{command}' on '#{target}'"
242
+ VanagonLogger.info "Executing '#{command}' on '#{target}'"
242
243
  if return_command_output
243
244
  ret = %x(#{ssh_command(port)} -T #{target} '#{command.gsub("'", "'\\\\''")}').chomp
244
245
  if $CHILD_STATUS.success?
@@ -261,7 +262,7 @@ class Vanagon
261
262
  # @raise [RuntimeError] If the command fails an exception is raised
262
263
  def local_command(command, return_command_output: false)
263
264
  clean_environment do
264
- warn "Executing '#{command}' locally"
265
+ VanagonLogger.info "Executing '#{command}' locally"
265
266
  if return_command_output
266
267
  ret = %x(#{command}).chomp
267
268
  if $CHILD_STATUS.success?
@@ -305,7 +306,7 @@ class Vanagon
305
306
  outfile ||= File.join(Dir.mktmpdir, File.basename(erbfile).sub(File.extname(erbfile), ""))
306
307
  output = erb_string(erbfile, opts[:binding])
307
308
  File.open(outfile, 'w') { |f| f.write output }
308
- warn "Generated: #{outfile}"
309
+ VanagonLogger.info "Generated: #{outfile}"
309
310
  FileUtils.rm_rf erbfile if remove_orig
310
311
  outfile
311
312
  end
@@ -18,7 +18,7 @@ Breaks: <%= get_replaces.map { |replace| "#{replace.replacement} #{replace.versi
18
18
  Conflicts: <%= get_conflicts.map { |conflict| "#{conflict.pkgname} #{conflict.version ? "(#{conflict.version})" : ""}" }.join(", ") %>
19
19
  <%- end -%>
20
20
  <%- unless get_requires.empty? -%>
21
- Depends: <%= get_requires.join(", ") %>
21
+ Depends: <%= get_requires.map { |req| "#{req.requirement} #{req.version ? "(#{req.version})" : ""}" }.join(", ") %>
22
22
  <%- end -%>
23
23
  <%- unless get_provides.empty? -%>
24
24
  Provides: <%= get_provides.map { |prov| prov.provide }.join(", ") %>
@@ -2,18 +2,29 @@
2
2
  <%- get_services.each do |service| -%>
3
3
  # switch based on systemd vs systemv
4
4
  #
5
- <%- if @platform.servicetype == "systemd" -%>
6
- if [ -z "$2" ]; then
7
- systemctl enable <%= service.name %>.service >/dev/null || :
8
- else
9
- systemctl try-restart <%= service.name %>.service >/dev/null || :
5
+ <%- if service.init_system.nil? || service.init_system.eql?('systemd') -%>
6
+ if [ -f '/proc/1/comm' ]; then
7
+ init_comm=`cat /proc/1/comm`
8
+ if [ "$init_comm" = "systemd" ]; then
9
+ if [ -z "$2" ]; then
10
+ systemctl enable <%= service.name %>.service >/dev/null || :
11
+ else
12
+ systemctl try-restart <%= service.name %>.service >/dev/null || :
13
+ fi
14
+ fi
10
15
  fi
11
- <%- elsif @platform.servicetype == "sysv" -%>
12
- if [ -x "<%= service.service_file %>" ]; then
13
- update-rc.d <%= service.name %> defaults > /dev/null
16
+ <%- end -%>
17
+ <%- if service.init_system.nil? || service.init_system.eql?('sysv') -%>
18
+ if [ -f '/proc/1/comm' ]; then
19
+ init_comm=`cat /proc/1/comm`
20
+ if [ "$init_comm" = "init" ]; then
21
+ if [ -x "<%= service.service_file %>" ]; then
22
+ update-rc.d <%= service.name %> defaults > /dev/null
14
23
 
15
- if [ -n "$2" ]; then
16
- invoke-rc.d <%= service.name %> condrestart || true
24
+ if [ -n "$2" ]; then
25
+ invoke-rc.d <%= service.name %> condrestart || true
26
+ fi
27
+ fi
17
28
  fi
18
29
  fi
19
30
  <%- end -%>
@@ -27,17 +38,17 @@ fi
27
38
 
28
39
  # Set up any specific permissions needed...
29
40
  <%- (get_directories + get_configfiles + get_files).select { |pathname| pathname.has_overrides? }.uniq.each do |file_or_directory| -%>
30
- <%= "chmod '#{file_or_directory.mode}' '#{file_or_directory.path}'" if file_or_directory.mode %>
41
+ <%= "chmod '#{file_or_directory.mode}' '#{file_or_directory.path}' &>/dev/null ||:" if file_or_directory.mode %>
31
42
  <%- if file_or_directory.owner -%>
32
43
  if getent passwd '<%= file_or_directory.owner %>' &> /dev/null; then
33
- chown '<%= file_or_directory.owner %>' '<%= file_or_directory.path %>'
44
+ chown '<%= file_or_directory.owner %>' '<%= file_or_directory.path %>' &>/dev/null ||:
34
45
  else
35
46
  echo "Error updating '<%= file_or_directory.path %>': user '<%= file_or_directory.owner %>' does not exist."
36
47
  fi
37
48
  <%- end -%>
38
49
  <%- if file_or_directory.group -%>
39
50
  if getent group '<%= file_or_directory.group %>' &> /dev/null; then
40
- chgrp '<%= file_or_directory.group %>' '<%= file_or_directory.path %>'
51
+ chgrp '<%= file_or_directory.group %>' '<%= file_or_directory.path %>' &>/dev/null ||:
41
52
  else
42
53
  echo "Error updating '<%= file_or_directory.path %>': group '<%= file_or_directory.group %>' does not exist."
43
54
  fi
@@ -13,11 +13,14 @@ fi
13
13
  <%- get_services.each do |service| -%>
14
14
  # switch based on systemd vs systemv
15
15
  #
16
- <%- if @platform.servicetype == "systemd" -%>
17
- systemctl daemon-reload >/dev/null 2>&1 || :
18
- <%- elsif @platform.servicetype == "sysv" -%>
19
- if [ "$1" = "purge" ] ; then
20
- update-rc.d <%= service.name %> remove > /dev/null
16
+ if [ -f '/proc/1/comm' ]; then
17
+ init_comm=`cat /proc/1/comm`
18
+ if [ "$init_comm" = "systemd" ]; then
19
+ systemctl daemon-reload >/dev/null 2>&1 || :
20
+ else
21
+ if [ "$1" = "purge" ] ; then
22
+ update-rc.d <%= service.name %> remove > /dev/null
23
+ fi
24
+ fi
21
25
  fi
22
- <%- end -%>
23
26
  <%- end -%>