mixlibrary-core 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE.txt +12 -12
- data/lib/mixlibrary/core/apps/_dependencies.rb +7 -7
- data/lib/mixlibrary/core/apps/shell.rb +3 -3
- data/lib/mixlibrary/core/apps/utilities.rb +4 -4
- data/lib/mixlibrary/core/shell/app.rb +55 -55
- data/lib/mixlibrary/core/shell/scripts/base.rb +32 -32
- data/lib/mixlibrary/core/shell/scripts/powershell.rb +1 -4
- data/lib/mixlibrary/core/shell/scripts/shelloutwrapper.rb +125 -111
- data/lib/mixlibrary/core/shell/scripts/windows_script.rb +54 -54
- data/lib/mixlibrary/core/version.rb +1 -1
- data/lib/mixlibrary/core/windows/features.rb +0 -4
- metadata +19 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69ae8d95dd76d56c1bc0e859399dd094395fe1c3
|
4
|
+
data.tar.gz: 58ce882bf60c55bf421bb5183af7f726dc8f73f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dc649157cd76158335d812ecbbb7b3d0fedbd3c1193d63ff88453666f9bd49fbd002a5447a07e78c6363a6b7a14bc332b2442d7f247a2b83d602ae3a2694d03
|
7
|
+
data.tar.gz: 45533757736c72b0490b3de850fc0f87e4c6bd9e482f58783f5bc1e33bd5a456def3a665e40df2986c2cfbcf7d5128020c2973a1ac60eb6e7497edae0f97e443
|
data/LICENSE.txt
CHANGED
@@ -1,13 +1,13 @@
|
|
1
|
-
Copyright 2014 EBSCO Information Services
|
2
|
-
|
3
|
-
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
-
you may not use this file except in compliance with the License.
|
5
|
-
You may obtain a copy of the License at
|
6
|
-
|
7
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
-
|
9
|
-
Unless required by applicable law or agreed to in writing, software
|
10
|
-
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
-
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
-
See the License for the specific language governing permissions and
|
1
|
+
Copyright 2014 EBSCO Information Services
|
2
|
+
|
3
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
you may not use this file except in compliance with the License.
|
5
|
+
You may obtain a copy of the License at
|
6
|
+
|
7
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
|
9
|
+
Unless required by applicable law or agreed to in writing, software
|
10
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
See the License for the specific language governing permissions and
|
13
13
|
limitations under the License.
|
@@ -1,7 +1,7 @@
|
|
1
|
-
#only needed for testing outside of chef executions. Should not be called from within a Chef Run
|
2
|
-
unless defined?(Chef::Mixin::ShellOut)
|
3
|
-
require 'chef'
|
4
|
-
end
|
5
|
-
unless defined?(Chef::Log)
|
6
|
-
require 'chef'
|
7
|
-
end
|
1
|
+
#only needed for testing outside of chef executions. Should not be called from within a Chef Run
|
2
|
+
unless defined?(Chef::Mixin::ShellOut)
|
3
|
+
require 'chef'
|
4
|
+
end
|
5
|
+
unless defined?(Chef::Log)
|
6
|
+
require 'chef'
|
7
|
+
end
|
@@ -1,3 +1,3 @@
|
|
1
|
-
require "mixlibrary/core/apps/_dependencies"
|
2
|
-
|
3
|
-
require "mixlibrary/core/shell/app"
|
1
|
+
require "mixlibrary/core/apps/_dependencies"
|
2
|
+
|
3
|
+
require "mixlibrary/core/shell/app"
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require "mixlibrary/core/apps/_dependencies"
|
2
|
-
|
3
|
-
require 'mixlibrary/core/utilities/ruby_info'
|
4
|
-
require "mixlibrary/core/utilities/windows_architecture_helper"
|
1
|
+
require "mixlibrary/core/apps/_dependencies"
|
2
|
+
|
3
|
+
require 'mixlibrary/core/utilities/ruby_info'
|
4
|
+
require "mixlibrary/core/utilities/windows_architecture_helper"
|
@@ -1,55 +1,55 @@
|
|
1
|
-
#This file defines the typical entrypoint into this shell code base. Other entrypoints can be used, but this one is currently made easiest
|
2
|
-
#by including an apps folder at the top level and including this file to get the pieces that are needed.
|
3
|
-
|
4
|
-
#Could you easily enough require the powershell.rb directly and just outright call it, sure. But most if not all of this code should be stateless. This
|
5
|
-
#implies static methods should be used. After a bunch of reading, there seems to be no real consensus on where static methods belong. I like the idea of classes
|
6
|
-
#but I found more people sticking these methods in the base module, which is what I am doing here. So the way one can interpret this file is it is the base methods
|
7
|
-
#that are exposed in its entirety for the Shell (sub-module) within this Gem. Since everything is stateless no need to expose classes directly unless it is overwhelmingly
|
8
|
-
#more complicated and many methods would need to be exposed (Scalability). (We are just scripting after all....)
|
9
|
-
|
10
|
-
require 'mixlibrary/core/shell/scripts/powershell'
|
11
|
-
require "mixlibrary/core/shell/shell_call"
|
12
|
-
|
13
|
-
module Mixlibrary
|
14
|
-
module Core
|
15
|
-
module Shell
|
16
|
-
|
17
|
-
#########################
|
18
|
-
#Scripts
|
19
|
-
#########################
|
20
|
-
def self.windows_script_out(shellType,script, options=nil, flags=nil,desiredarchitecture=nil)
|
21
|
-
return run_windows_script(shellType,false,script, options, flags,desiredarchitecture)
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.windows_script_out!(shellType,script, options=nil, flags=nil,desiredarchitecture=nil )
|
25
|
-
return run_windows_script(shellType,true,script, options, flags,desiredarchitecture)
|
26
|
-
end
|
27
|
-
|
28
|
-
#########################
|
29
|
-
#Shell Out
|
30
|
-
#########################
|
31
|
-
def self.shell_out!(command, options=nil)
|
32
|
-
shellclass=Shell::ShellCall.new
|
33
|
-
return shellclass.shell!(command, options)
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.shell_out(command, options=nil)
|
37
|
-
shellclass=Shell::ShellCall.new
|
38
|
-
return shellclass.shell(command, options)
|
39
|
-
end
|
40
|
-
|
41
|
-
private
|
42
|
-
def self.run_windows_script(shellType, validate, script, options, flags, architecture)
|
43
|
-
case shellType
|
44
|
-
when :powershell
|
45
|
-
|
46
|
-
obj= Shell::Scripts::Powershell.new(script, validate, options, flags,architecture)
|
47
|
-
return obj.orchestrate
|
48
|
-
|
49
|
-
else
|
50
|
-
raise "Shell not supported. Currently supports: :powershell for now!"
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
1
|
+
#This file defines the typical entrypoint into this shell code base. Other entrypoints can be used, but this one is currently made easiest
|
2
|
+
#by including an apps folder at the top level and including this file to get the pieces that are needed.
|
3
|
+
|
4
|
+
#Could you easily enough require the powershell.rb directly and just outright call it, sure. But most if not all of this code should be stateless. This
|
5
|
+
#implies static methods should be used. After a bunch of reading, there seems to be no real consensus on where static methods belong. I like the idea of classes
|
6
|
+
#but I found more people sticking these methods in the base module, which is what I am doing here. So the way one can interpret this file is it is the base methods
|
7
|
+
#that are exposed in its entirety for the Shell (sub-module) within this Gem. Since everything is stateless no need to expose classes directly unless it is overwhelmingly
|
8
|
+
#more complicated and many methods would need to be exposed (Scalability). (We are just scripting after all....)
|
9
|
+
|
10
|
+
require 'mixlibrary/core/shell/scripts/powershell'
|
11
|
+
require "mixlibrary/core/shell/shell_call"
|
12
|
+
|
13
|
+
module Mixlibrary
|
14
|
+
module Core
|
15
|
+
module Shell
|
16
|
+
|
17
|
+
#########################
|
18
|
+
#Scripts
|
19
|
+
#########################
|
20
|
+
def self.windows_script_out(shellType,script, options=nil, flags=nil,desiredarchitecture=nil)
|
21
|
+
return run_windows_script(shellType,false,script, options, flags,desiredarchitecture)
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.windows_script_out!(shellType,script, options=nil, flags=nil,desiredarchitecture=nil )
|
25
|
+
return run_windows_script(shellType,true,script, options, flags,desiredarchitecture)
|
26
|
+
end
|
27
|
+
|
28
|
+
#########################
|
29
|
+
#Shell Out
|
30
|
+
#########################
|
31
|
+
def self.shell_out!(command, options=nil)
|
32
|
+
shellclass=Shell::ShellCall.new
|
33
|
+
return shellclass.shell!(command, options)
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.shell_out(command, options=nil)
|
37
|
+
shellclass=Shell::ShellCall.new
|
38
|
+
return shellclass.shell(command, options)
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def self.run_windows_script(shellType, validate, script, options, flags, architecture)
|
43
|
+
case shellType
|
44
|
+
when :powershell
|
45
|
+
|
46
|
+
obj= Shell::Scripts::Powershell.new(script, validate, options, flags,architecture)
|
47
|
+
return obj.orchestrate
|
48
|
+
|
49
|
+
else
|
50
|
+
raise "Shell not supported. Currently supports: :powershell for now!"
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -1,32 +1,32 @@
|
|
1
|
-
require "mixlibrary/core/shell/scripts/shelloutwrapper"
|
2
|
-
|
3
|
-
module Mixlibrary
|
4
|
-
module Core
|
5
|
-
module Shell
|
6
|
-
class Scripts
|
7
|
-
|
8
|
-
#Base class for all script classes. Provides an Interface of sorts that all other classes must implement and also provides the base methods that would need to be implemented.
|
9
|
-
class Base
|
10
|
-
|
11
|
-
#Orchestrates running the script. Might be as simple as calling shell_out or more complicated like doing syntax validation of the script before execution
|
12
|
-
def orchestrate
|
13
|
-
raise "Not Implemented Exception"
|
14
|
-
end
|
15
|
-
|
16
|
-
protected
|
17
|
-
|
18
|
-
def run_command(shell_executable, flags, filename_prefix, file_extension, code,shellout_options, eval_error)
|
19
|
-
shellobj =Scripts::ShellOutWrapper.new(shell_executable, flags, filename_prefix, file_extension, code, shellout_options)
|
20
|
-
|
21
|
-
if(eval_error)
|
22
|
-
return shellobj.run_command!
|
23
|
-
else
|
24
|
-
return shellobj.run_command
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
1
|
+
require "mixlibrary/core/shell/scripts/shelloutwrapper"
|
2
|
+
|
3
|
+
module Mixlibrary
|
4
|
+
module Core
|
5
|
+
module Shell
|
6
|
+
class Scripts
|
7
|
+
|
8
|
+
#Base class for all script classes. Provides an Interface of sorts that all other classes must implement and also provides the base methods that would need to be implemented.
|
9
|
+
class Base
|
10
|
+
|
11
|
+
#Orchestrates running the script. Might be as simple as calling shell_out or more complicated like doing syntax validation of the script before execution
|
12
|
+
def orchestrate
|
13
|
+
raise "Not Implemented Exception"
|
14
|
+
end
|
15
|
+
|
16
|
+
protected
|
17
|
+
|
18
|
+
def run_command(shell_executable, flags, filename_prefix, file_extension, code,shellout_options, eval_error)
|
19
|
+
shellobj =Scripts::ShellOutWrapper.new(shell_executable, flags, filename_prefix, file_extension, code, shellout_options)
|
20
|
+
|
21
|
+
if(eval_error)
|
22
|
+
return shellobj.run_command!
|
23
|
+
else
|
24
|
+
return shellobj.run_command
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -31,10 +31,7 @@ module Mixlibrary
|
|
31
31
|
syntax_check()
|
32
32
|
|
33
33
|
myscriptstring = finalscript()
|
34
|
-
|
35
|
-
Chef::Log::debug("-----------------------------------------------------")
|
36
|
-
Chef::Log::debug(myscriptstring)
|
37
|
-
Chef::Log::debug("-----------------------------------------------------")
|
34
|
+
|
38
35
|
return run_command(shell,flags,filename,file_extension, myscriptstring, @options, @validate)
|
39
36
|
end
|
40
37
|
|
@@ -1,111 +1,125 @@
|
|
1
|
-
#Wraps calling shell out with any script file. Will create the script file execute the shell out command and delete the file once complete
|
2
|
-
|
3
|
-
require "mixlibrary/core/shell/shell_call"
|
4
|
-
module Mixlibrary
|
5
|
-
module Core
|
6
|
-
module Shell
|
7
|
-
class Scripts
|
8
|
-
class ShellOutWrapper
|
9
|
-
@exe
|
10
|
-
@flags
|
11
|
-
@filename
|
12
|
-
@fileext
|
13
|
-
@code
|
14
|
-
@shellout_options
|
15
|
-
|
16
|
-
#runtime
|
17
|
-
@script_file
|
18
|
-
|
19
|
-
def initialize(exe, flags, filename, fileext, code, shellout_options)
|
20
|
-
@exe=exe
|
21
|
-
@flags=flags
|
22
|
-
@filename=filename
|
23
|
-
@fileext=fileext
|
24
|
-
@code=code
|
25
|
-
if(shellout_options==nil)
|
26
|
-
@shellout_options= Hash.new()
|
27
|
-
else
|
28
|
-
@shellout_options=shellout_options
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
public
|
33
|
-
#Supported options
|
34
|
-
#opts[:domain]
|
35
|
-
#opts[:password]
|
36
|
-
#opts[:timeout] = @new_resource.timeout || 3600
|
37
|
-
#opts[:returns] = @new_resource.returns if @new_resource.returns
|
38
|
-
#opts[:environment] = @new_resource.environment if @new_resource.environment
|
39
|
-
#opts[:user] = @new_resource.user if @new_resource.user
|
40
|
-
#opts[:group] = @new_resource.group if @new_resource.group
|
41
|
-
#opts[:cwd] = @new_resource.cwd if @new_resource.cwd
|
42
|
-
#opts[:umask] = @new_resource.umask if @new_resource.umask
|
43
|
-
#opts[:log_level] = :info
|
44
|
-
#opts[:log_tag] = @new_resource.to_s
|
45
|
-
#cmd = Chef::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp')
|
46
|
-
#puts "#{script_file.path}"
|
47
|
-
|
48
|
-
def run_command
|
49
|
-
return shellout(false)
|
50
|
-
end
|
51
|
-
|
52
|
-
def run_command!
|
53
|
-
return shellout(true)
|
54
|
-
end
|
55
|
-
|
56
|
-
private
|
57
|
-
|
58
|
-
def set_owner_and_group
|
59
|
-
# FileUtils itself implements a no-op if +user+ or +group+ are nil
|
60
|
-
# You can prove this by running FileUtils.chown(nil,nil,'/tmp/file')
|
61
|
-
# as an unprivileged user.
|
62
|
-
#puts "#{@shellout_options.inspect}"
|
63
|
-
::FileUtils.chown(@shellout_options[:user], @shellout_options[:group], @script_file.path)
|
64
|
-
end
|
65
|
-
|
66
|
-
def script_file
|
67
|
-
#puts "File name #{filename}"
|
68
|
-
@script_file ||= Tempfile.open([@filename, @fileext])
|
69
|
-
end
|
70
|
-
|
71
|
-
def unlink_script_file
|
72
|
-
@script_file && @script_file.close!
|
73
|
-
@script_file=nil
|
74
|
-
end
|
75
|
-
|
76
|
-
def create_file ()
|
77
|
-
#Output script to file path
|
78
|
-
script_file.puts(@code)
|
79
|
-
script_file.close
|
80
|
-
|
81
|
-
set_owner_and_group
|
82
|
-
end
|
83
|
-
|
84
|
-
def shellout(eval_error)
|
85
|
-
begin
|
86
|
-
create_file()
|
87
|
-
|
88
|
-
shellclass=Shell::ShellCall.new
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
1
|
+
#Wraps calling shell out with any script file. Will create the script file execute the shell out command and delete the file once complete
|
2
|
+
|
3
|
+
require "mixlibrary/core/shell/shell_call"
|
4
|
+
module Mixlibrary
|
5
|
+
module Core
|
6
|
+
module Shell
|
7
|
+
class Scripts
|
8
|
+
class ShellOutWrapper
|
9
|
+
@exe
|
10
|
+
@flags
|
11
|
+
@filename
|
12
|
+
@fileext
|
13
|
+
@code
|
14
|
+
@shellout_options
|
15
|
+
|
16
|
+
#runtime
|
17
|
+
@script_file
|
18
|
+
|
19
|
+
def initialize(exe, flags, filename, fileext, code, shellout_options)
|
20
|
+
@exe=exe
|
21
|
+
@flags=flags
|
22
|
+
@filename=filename
|
23
|
+
@fileext=fileext
|
24
|
+
@code=code
|
25
|
+
if(shellout_options==nil)
|
26
|
+
@shellout_options= Hash.new()
|
27
|
+
else
|
28
|
+
@shellout_options=shellout_options
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
public
|
33
|
+
#Supported options
|
34
|
+
#opts[:domain]
|
35
|
+
#opts[:password]
|
36
|
+
#opts[:timeout] = @new_resource.timeout || 3600
|
37
|
+
#opts[:returns] = @new_resource.returns if @new_resource.returns
|
38
|
+
#opts[:environment] = @new_resource.environment if @new_resource.environment
|
39
|
+
#opts[:user] = @new_resource.user if @new_resource.user
|
40
|
+
#opts[:group] = @new_resource.group if @new_resource.group
|
41
|
+
#opts[:cwd] = @new_resource.cwd if @new_resource.cwd
|
42
|
+
#opts[:umask] = @new_resource.umask if @new_resource.umask
|
43
|
+
#opts[:log_level] = :info
|
44
|
+
#opts[:log_tag] = @new_resource.to_s
|
45
|
+
#cmd = Chef::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp')
|
46
|
+
#puts "#{script_file.path}"
|
47
|
+
|
48
|
+
def run_command
|
49
|
+
return shellout(false)
|
50
|
+
end
|
51
|
+
|
52
|
+
def run_command!
|
53
|
+
return shellout(true)
|
54
|
+
end
|
55
|
+
|
56
|
+
private
|
57
|
+
|
58
|
+
def set_owner_and_group
|
59
|
+
# FileUtils itself implements a no-op if +user+ or +group+ are nil
|
60
|
+
# You can prove this by running FileUtils.chown(nil,nil,'/tmp/file')
|
61
|
+
# as an unprivileged user.
|
62
|
+
#puts "#{@shellout_options.inspect}"
|
63
|
+
::FileUtils.chown(@shellout_options[:user], @shellout_options[:group], @script_file.path)
|
64
|
+
end
|
65
|
+
|
66
|
+
def script_file
|
67
|
+
#puts "File name #{filename}"
|
68
|
+
@script_file ||= Tempfile.open([@filename, @fileext])
|
69
|
+
end
|
70
|
+
|
71
|
+
def unlink_script_file
|
72
|
+
@script_file && @script_file.close!
|
73
|
+
@script_file=nil
|
74
|
+
end
|
75
|
+
|
76
|
+
def create_file ()
|
77
|
+
#Output script to file path
|
78
|
+
script_file.puts(@code)
|
79
|
+
script_file.close
|
80
|
+
|
81
|
+
set_owner_and_group
|
82
|
+
end
|
83
|
+
|
84
|
+
def shellout(eval_error)
|
85
|
+
begin
|
86
|
+
create_file()
|
87
|
+
|
88
|
+
shellclass=Shell::ShellCall.new
|
89
|
+
|
90
|
+
Chef::Log::debug("Script Contents:")
|
91
|
+
Chef::Log::debug("-----------------------------------------------------")
|
92
|
+
Chef::Log::debug(@code)
|
93
|
+
Chef::Log::debug("-----------------------------------------------------")
|
94
|
+
|
95
|
+
result = nil
|
96
|
+
|
97
|
+
if(eval_error)
|
98
|
+
result = shellclass.shell!("#{@exe} #{@flags} #{@script_file.path}", @shellout_options)
|
99
|
+
else
|
100
|
+
result = shellclass.shell("#{@exe} #{@flags} #{@script_file.path}", @shellout_options)
|
101
|
+
end
|
102
|
+
|
103
|
+
unless result.nil?
|
104
|
+
Chef::Log.debug("Command output:#{result.stdout}")
|
105
|
+
Chef::Log.debug("Command Error:#{result.stderr}")
|
106
|
+
Chef::Log.debug("Command Exit Code:#{result.exitstatus}")
|
107
|
+
end
|
108
|
+
|
109
|
+
return result
|
110
|
+
|
111
|
+
rescue Exception => e
|
112
|
+
#puts e.message
|
113
|
+
#puts e.backtrace.inspect
|
114
|
+
raise
|
115
|
+
|
116
|
+
ensure
|
117
|
+
unlink_script_file
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
@@ -1,55 +1,55 @@
|
|
1
|
-
#All windows scripts will inherit from here
|
2
|
-
require "mixlibrary/core/shell/scripts/base"
|
3
|
-
require 'mixlibrary/core/apps/utilities'
|
4
|
-
|
5
|
-
module Mixlibrary
|
6
|
-
module Core
|
7
|
-
module Shell
|
8
|
-
class Scripts
|
9
|
-
class WindowsScript < Base
|
10
|
-
|
11
|
-
protected
|
12
|
-
|
13
|
-
@targetarchitecutre = nil;
|
14
|
-
@should_override = nil
|
15
|
-
|
16
|
-
def initialize(architecture)
|
17
|
-
super()
|
18
|
-
|
19
|
-
#The target arch is either what the machine is or passed in parameter
|
20
|
-
@targetarchitecutre = architecture.nil? ? Utilities::WindowsArchitectureHelper.architecture : architecture
|
21
|
-
@should_override = Utilities::WindowsArchitectureHelper.wow64_architecture_override_required?(@targetarchitecutre)
|
22
|
-
|
23
|
-
#why do we care here? If user wants a 32bit process call the 32 bit executable?
|
24
|
-
if ( @targetarchitecutre == :i386 )
|
25
|
-
if (RubyInfo.architecture==:x86_64)
|
26
|
-
raise "Support for the i386 architecture from a 64-bit Ruby runtime is not supported. Please call the specific 32 bit assembly directly"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
def run_command(shell_executable, flags, filename_prefix, file_extension, code,shellout_options, eval_error)
|
33
|
-
wow64_redirection_state = nil
|
34
|
-
|
35
|
-
if @should_override
|
36
|
-
#puts "Disabling redirection"
|
37
|
-
wow64_redirection_state = Utilities::WindowsArchitectureHelper.disable_wow64_file_redirection()
|
38
|
-
end
|
39
|
-
|
40
|
-
begin
|
41
|
-
return super(shell_executable, flags, filename_prefix, file_extension, code,shellout_options, eval_error)
|
42
|
-
rescue
|
43
|
-
raise
|
44
|
-
ensure
|
45
|
-
if ! wow64_redirection_state.nil?
|
46
|
-
#puts "Restoring redirection"
|
47
|
-
Utilities::WindowsArchitectureHelper.restore_wow64_file_redirection(wow64_redirection_state)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|
1
|
+
#All windows scripts will inherit from here
|
2
|
+
require "mixlibrary/core/shell/scripts/base"
|
3
|
+
require 'mixlibrary/core/apps/utilities'
|
4
|
+
|
5
|
+
module Mixlibrary
|
6
|
+
module Core
|
7
|
+
module Shell
|
8
|
+
class Scripts
|
9
|
+
class WindowsScript < Base
|
10
|
+
|
11
|
+
protected
|
12
|
+
|
13
|
+
@targetarchitecutre = nil;
|
14
|
+
@should_override = nil
|
15
|
+
|
16
|
+
def initialize(architecture)
|
17
|
+
super()
|
18
|
+
|
19
|
+
#The target arch is either what the machine is or passed in parameter
|
20
|
+
@targetarchitecutre = architecture.nil? ? Utilities::WindowsArchitectureHelper.architecture : architecture
|
21
|
+
@should_override = Utilities::WindowsArchitectureHelper.wow64_architecture_override_required?(@targetarchitecutre)
|
22
|
+
|
23
|
+
#why do we care here? If user wants a 32bit process call the 32 bit executable?
|
24
|
+
if ( @targetarchitecutre == :i386 )
|
25
|
+
if (RubyInfo.architecture==:x86_64)
|
26
|
+
raise "Support for the i386 architecture from a 64-bit Ruby runtime is not supported. Please call the specific 32 bit assembly directly"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
def run_command(shell_executable, flags, filename_prefix, file_extension, code,shellout_options, eval_error)
|
33
|
+
wow64_redirection_state = nil
|
34
|
+
|
35
|
+
if @should_override
|
36
|
+
#puts "Disabling redirection"
|
37
|
+
wow64_redirection_state = Utilities::WindowsArchitectureHelper.disable_wow64_file_redirection()
|
38
|
+
end
|
39
|
+
|
40
|
+
begin
|
41
|
+
return super(shell_executable, flags, filename_prefix, file_extension, code,shellout_options, eval_error)
|
42
|
+
rescue
|
43
|
+
raise
|
44
|
+
ensure
|
45
|
+
if ! wow64_redirection_state.nil?
|
46
|
+
#puts "Restoring redirection"
|
47
|
+
Utilities::WindowsArchitectureHelper.restore_wow64_file_redirection(wow64_redirection_state)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
55
|
end
|
@@ -23,7 +23,6 @@ module Mixlibrary
|
|
23
23
|
EOF
|
24
24
|
|
25
25
|
procobj = Mixlibrary::Core::Shell.windows_script_out!(:powershell, script)
|
26
|
-
Chef::Log.debug("Command output: #{procobj.stdout}")
|
27
26
|
end
|
28
27
|
|
29
28
|
def install_feature()
|
@@ -34,7 +33,6 @@ module Mixlibrary
|
|
34
33
|
EOF
|
35
34
|
|
36
35
|
procobj = Mixlibrary::Core::Shell.windows_script_out!(:powershell, script)
|
37
|
-
Chef::Log.debug("Command output: #{procobj.stdout}")
|
38
36
|
end
|
39
37
|
|
40
38
|
def is_feature_available?()
|
@@ -58,7 +56,6 @@ module Mixlibrary
|
|
58
56
|
EOF
|
59
57
|
|
60
58
|
procobj = Mixlibrary::Core::Shell.windows_script_out(:powershell, script)
|
61
|
-
Chef::Log.info("Command output:#{procobj.stdout}")
|
62
59
|
|
63
60
|
return procobj.stderr.empty? && procobj.stdout !~ /Removed/i && procobj.exitstatus==5
|
64
61
|
end
|
@@ -75,7 +72,6 @@ module Mixlibrary
|
|
75
72
|
EOF
|
76
73
|
|
77
74
|
procobj = Mixlibrary::Core::Shell.windows_script_out!(:powershell, script)
|
78
|
-
Chef::Log.debug("Command output:#{procobj.stdout}")
|
79
75
|
procobj.stderr.empty? && (procobj.stdout =~ /False/i) == nil && (procobj.stdout =~ /true/i) != nil
|
80
76
|
|
81
77
|
end
|
metadata
CHANGED
@@ -1,103 +1,103 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixlibrary-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nicholas Carpenter
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '5.5'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '5.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: yard
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0.8'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0.8'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: minitest-reporters
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - ~>
|
73
|
+
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '1.0'
|
76
76
|
type: :development
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - ~>
|
80
|
+
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '1.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: chef
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
|
-
- -
|
87
|
+
- - ">="
|
88
88
|
- !ruby/object:Gem::Version
|
89
89
|
version: '11.16'
|
90
|
-
- - <
|
90
|
+
- - "<"
|
91
91
|
- !ruby/object:Gem::Version
|
92
92
|
version: '13'
|
93
93
|
type: :runtime
|
94
94
|
prerelease: false
|
95
95
|
version_requirements: !ruby/object:Gem::Requirement
|
96
96
|
requirements:
|
97
|
-
- -
|
97
|
+
- - ">="
|
98
98
|
- !ruby/object:Gem::Version
|
99
99
|
version: '11.16'
|
100
|
-
- - <
|
100
|
+
- - "<"
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '13'
|
103
103
|
description: 'MixLib for creating Core libraries in ruby for automating machines. This
|
@@ -134,17 +134,17 @@ require_paths:
|
|
134
134
|
- lib
|
135
135
|
required_ruby_version: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
|
-
- -
|
137
|
+
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
139
|
version: '0'
|
140
140
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
|
-
- -
|
142
|
+
- - ">="
|
143
143
|
- !ruby/object:Gem::Version
|
144
144
|
version: '2.4'
|
145
145
|
requirements: []
|
146
146
|
rubyforge_project:
|
147
|
-
rubygems_version: 2.4.
|
147
|
+
rubygems_version: 2.4.8
|
148
148
|
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: MixLib for creating Core libraries in ruby for automating machines.
|