Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Small updates to Exec resource.

Fix class name for init.pp
  • Loading branch information...
commit fe6ca267f3a67f2d03d37bcda90aa84c46d034b3 1 parent 4f908f7
@relistan authored root committed
Showing with 14 additions and 4 deletions.
  1. +14 −4 convert.rb
View
18 convert.rb
@@ -123,14 +123,19 @@ def initialize output, cookbook_name, recipes_path, files_path, templates_path,
def short_fname
if fname =~ /default.rb$/
# We don't want output files called default.rb
- @short_fname = "#{@cookbook_name}.rb"
+ @short_fname = "init.pp"
else
@short_fname = File.basename(@fname)
end
end
def class_name
- @class_name ||= "#{@cookbook_name}::#{short_fname.sub(/\.rb$/, '')}"
+ return @class_name if @class_name
+ if short_fname == "init.pp"
+ @class_name = @cookbook_name
+ else
+ @class_name = "#{@cookbook_name}::#{short_fname.sub(/\.rb$/, '')}"
+ end
end
def puts *args
@@ -241,8 +246,13 @@ def node *args
# Exec -------
def command arg
- @statements['path'] << "'/bin:/usr/bin:/sbin:/usr/sbin'" if @context.current_chef_resource != 'cron'
- @statements['command'] << %~" echo \\"#{arg.gsub(/"/, '\\\\\"')}\\" | bash"~ # OMG!
+ # We don't set a path... the user should have a default defined for the resource type
+ if arg =~ /[|;]/
+ # If it contains a pipe, we need a real shell to run it in
+ @statements['command'] << %~"bash -c \\"#{arg.gsub(/"/, '\\\\\"')}\\""~
+ else
+ @statements['command'] << %~"#{arg.gsub(/"/, '\\\\"')}"~
+ end
self
end
# ------------
Please sign in to comment.
Something went wrong with that request. Please try again.