app/cyclid/plugins/action/script.rb in cyclid-0.3.3 vs app/cyclid/plugins/action/script.rb in cyclid-0.4.0
- old
+ new
@@ -45,13 +45,12 @@
else
file = "cyclid_#{SecureRandom.hex(16)}"
File.join('/', 'tmp', file)
end
- @env = args[:env] if args.include? :env
-
- Cyclid.logger.debug "script: '#{@script}' path: #{@path}"
+ @env = args[:env]
+ @sudo = args[:sudo]
end
# Run the script action
def perform(log)
begin
@@ -70,17 +69,25 @@
io = StringIO.new(script)
@transport.upload(io, path)
# Execute the script
log.write("Running script from #{path}...\n")
- success = @transport.exec("chmod +x #{path} && #{path}")
+ success = @transport.exec("chmod +x #{path} && #{path}", sudo: @sudo)
rescue KeyError => ex
# Interpolation failed
log.write "#{ex.message}\n"
success = false
end
[success, @transport.exit_code]
+ end
+
+ # Plugin metadata
+ def self.metadata
+ super.merge!(version: Cyclid::Api::VERSION,
+ license: 'Apache-2.0',
+ author: 'Liqwyd Ltd.',
+ homepage: 'http://docs.cyclid.io')
end
# Register this plugin
register_plugin 'script'
end