chef-zero-scheduled-task 0.0.10 → 0.0.11

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
2
  SHA1:
3
- metadata.gz: a3483f32db095dc30108f0c7d332329300243841
4
- data.tar.gz: 87a6c6564a8d51c13c88ca9d08fdfb7159b203a7
3
+ metadata.gz: 9856132650063f5768cf8d2ec0784db9e958854a
4
+ data.tar.gz: 5b8c13e93070018f9730405659f1dd044bcb7f53
5
5
  SHA512:
6
- metadata.gz: 5d15db7fb0e10dec5f23c70cac9cd9369d4b8d0bff1883cf38b5fdf62fc22dd161893127bf2de6018447a4bbd482a85508ecdc148f980d8da3e2cc5f6ec73d66
7
- data.tar.gz: 88d856b13222ac3374a836bf3c8e56cd58d7136029621d3d4042847da74efa5887e66958130149a2c24c8d12816b9f56e2327bfa37b35281c23b9e98cec3dee8
6
+ metadata.gz: 2c2c2658b28130e8706a51c0022ccfb832739cf112bc32ca9fa6047146d2fd98c448e0941707dbc0ed6d1ae1d8e2d69207828b60e789ba3f025a17e398d08c90
7
+ data.tar.gz: 637e521f09f4ebedce7e3d2da615c51f017b0c75342850cee9c152d0220c0bd1b82ead37294db79579f1298d51ed96a28aa557fc20c9f7989eb825d9c0c19903
@@ -2,7 +2,7 @@ module Chef
2
2
  module Zero
3
3
  module Scheduled
4
4
  module Task
5
- VERSION = "0.0.10"
5
+ VERSION = "0.0.11"
6
6
  end
7
7
  end
8
8
  end
@@ -30,18 +30,6 @@ module Kitchen
30
30
 
31
31
  default_config :task_password
32
32
 
33
- def prepare_command
34
- if windows_os?
35
- debug("Serializing $env:temp")
36
- wrap_shell_code(<<-EOH
37
- "`$env:temp = '$env:temp'" |
38
- out-file $env:temp/kitchen/env.ps1
39
- EOH
40
- )
41
- end
42
- super
43
- end
44
-
45
33
  def init_command
46
34
  if windows_os?
47
35
  info("Creating the scheduled task.")
@@ -54,7 +42,7 @@ module Kitchen
54
42
  def run_command
55
43
  if windows_os?
56
44
  script = "$script = @'\n#{scheduled_task_command_script}\n'@\n" \
57
- "\n$Script | out-file \"$env:temp/kitchen/chef-client-script.ps1\"" \
45
+ "\n$ExecutionContext.InvokeCommand.ExpandString($Script) | out-file \"$env:temp/kitchen/chef-client-script.ps1\"" \
58
46
  "\n#{run_scheduled_task_command}"
59
47
  wrap_shell_code(script)
60
48
  else
@@ -92,24 +80,25 @@ module Kitchen
92
80
 
93
81
  def run_scheduled_task_command
94
82
  <<-EOH
95
- try {
96
- $npipeServer = new-object System.IO.Pipes.NamedPipeServerStream(
97
- 'task', [System.IO.Pipes.PipeDirection]::In)
98
- $pipeReader = new-object System.IO.StreamReader($npipeServer)
99
- schtasks /run /tn "chef-tk"
100
- $npipeserver.waitforconnection()
101
- $host.ui.writeline('Connected to the scheduled task.')
102
- while ($npipeserver.IsConnected) {
103
- $output = $pipereader.ReadLine()
104
- if ($output -like 'SCHEDULED_TASK_DONE:*') {
105
- $exit_code = ($output -replace 'SCHEDULED_TASK_DONE:').trim()
106
- }
107
- else { $host.ui.WriteLine($output) } } }
108
- finally {
109
- $pipereader.dispose()
110
- $npipeserver.dispose()
111
- $host.setshouldexit($exit_code)
112
- }
83
+ try {
84
+ Add-Type -AssemblyName System.Core
85
+ $npipeServer = new-object System.IO.Pipes.NamedPipeServerStream('task',
86
+ [System.IO.Pipes.PipeDirection]::In)
87
+ $pipeReader = new-object System.IO.StreamReader($npipeServer)
88
+ schtasks /run /tn "chef-tk"
89
+ $npipeserver.waitforconnection()
90
+ $host.ui.writeline('Connected to the scheduled task.')
91
+ while ($npipeserver.IsConnected) {
92
+ $output = $pipereader.ReadLine()
93
+ if ($output -like 'SCHEDULED_TASK_DONE:*') {
94
+ $exit_code = ($output -replace 'SCHEDULED_TASK_DONE:').trim()
95
+ }
96
+ else { $host.ui.WriteLine($output) } } }
97
+ finally {
98
+ $pipereader.dispose()
99
+ $npipeserver.dispose()
100
+ $host.setshouldexit($exit_code)
101
+ }
113
102
  EOH
114
103
  end
115
104
 
@@ -138,20 +127,20 @@ module Kitchen
138
127
 
139
128
  def scheduled_task_command_script
140
129
  <<-EOH
141
- . $psscriptroot/env.ps1;
142
- start-sleep -seconds 5;
143
- $npipeClient = new-object System.IO.Pipes.NamedPipeClientStream(
144
- $env:ComputerName, 'task', [System.IO.Pipes.PipeDirection]::Out);
145
- $npipeclient.connect();
146
- $pipeWriter = new-object System.IO.StreamWriter($npipeClient);
147
- $pipeWriter.AutoFlush = $true;
148
- #{client_zero_command} |
149
- foreach-object {} {$pipewriter.writeline($_)} {
150
- $pipewriter.writeline("SCHEDULED_TASK_DONE: $LastExitCode");
151
- $pipewriter.dispose();
152
- $npipeclient.dispose()
153
- }
154
- EOH
130
+ Add-Type -AssemblyName System.Core
131
+ start-sleep -seconds 5;
132
+ `$npipeClient = new-object System.IO.Pipes.NamedPipeClientStream(`$env:ComputerName,
133
+ `'task`', [System.IO.Pipes.PipeDirection]::Out);
134
+ `$npipeclient.connect();
135
+ `$pipeWriter = new-object System.IO.StreamWriter(`$npipeClient);
136
+ `$pipeWriter.AutoFlush = `$true;
137
+ #{client_zero_command} |
138
+ foreach-object {} {`$pipewriter.writeline(`$_)} {
139
+ `$pipewriter.writeline(`"SCHEDULED_TASK_DONE: `$LastExitCode`");
140
+ `$pipewriter.dispose();
141
+ `$npipeclient.dispose()
142
+ }
143
+ EOH
155
144
  end
156
145
 
157
146
  def prepare_client_zero_script
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-zero-scheduled-task
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.10
4
+ version: 0.0.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Murawski
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-26 00:00:00.000000000 Z
11
+ date: 2016-03-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen