-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
958 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,78 @@ | ||
<# | ||
#> | ||
|
||
|
||
if ($env:PACKER_BUILDER_TYPE -match 'vmware') | ||
{ | ||
$share_name = "\\vmware-host\Shared Folders" | ||
} | ||
elseif ($env:PACKER_BUILDER_TYPE -match 'virtualbox') | ||
[CmdletBinding(SupportsShouldProcess=$true)] | ||
Param( | ||
) | ||
begin | ||
{ | ||
$share_name = "\\vboxsrv" | ||
Write-Output "Script started at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | ||
} | ||
elseif ($env:PACKER_BUILDER_TYPE -match 'parallels') | ||
process | ||
{ | ||
$share_name = "\\psf" | ||
} | ||
else | ||
{ | ||
Write-Warning "Unknown Packer builder ${env:PACKER_BUILDER_TYPE}, ignoring" | ||
exit 0 | ||
} | ||
if (Test-Path $env:USERPROFILE/share-log.info) | ||
{ | ||
$ShareArgs = @{ PSProvider = 'FileSystem'; ErrorAction = 'Stop' } | ||
$ShareInfo = Get-Content $env:USERPROFILE/share-log.info -Raw | ConvertFrom-Json | ||
|
||
$log_dir = Join-Path $share_name "log" | ||
if ($ShareInfo.DriveLetter -ne $null) | ||
{ | ||
if ($ShareInfo.User -ne $null) | ||
{ | ||
if ($ShareInfo.Password -eq $null) | ||
{ | ||
Throw "No password for $($ShareInfo.User) in $($env:USERPROFILE)/share-log.info" | ||
exit 1 | ||
} | ||
$ShareArgs['Credential'] = New-Object System.Management.Automation.PSCredential($ShareInfo.User, (ConvertTo-SecureString -String $ShareInfo.Password -AsPlainText -Force)) | ||
} | ||
$Drive = New-PSDrive -Name $ShareInfo.DriveLetter -Root $ShareInfo.Path @ShareArgs | ||
$log_dir = $Drive.Root | ||
} | ||
else | ||
{ | ||
$log_dir = $ShareInfo.Path | ||
} | ||
Write-Output "Using Share at $log_dir" | ||
} | ||
else | ||
{ | ||
Write-Output "Share log information was not found" | ||
Write-Warning "No log will be backed up" | ||
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | ||
exit | ||
} | ||
if ([string]::IsNullOrEmpty($log_dir)) | ||
{ | ||
Throw "No share to use from $($env:USERPROFILE)/share-log.info" | ||
exit 2 | ||
} | ||
|
||
if (Test-Path "C:\ProgramData\chocolatey\logs\chocolatey.log") | ||
{ | ||
Copy-Item C:\ProgramData\chocolatey\logs\chocolatey.log (Join-Path $log_dir "packer-build-${env:PACKER_BUILDER_TYPE}-${env:PACKER_BUILD_NAME}-chocolatey.log") | ||
} | ||
$log_dir = (Join-Path $log_dir "${env:PACKER_BUILDER_TYPE}-${env:PACKER_BUILD_NAME}-$(Get-Date -Format 'yyyyMMddHHmmss')") | ||
if (! (Test-Path $log_dir)) { New-Item -ItemType Directory -Path $log_dir -ErrorAction Stop | Out-Null } | ||
|
||
if (Test-Path "C:\Windows\Logs\icserver-*.log") | ||
{ | ||
Copy-Item C:\Windows\Logs\icserver-*.log (Join-Path $log_dir "packer-build-${env:PACKER_BUILDER_TYPE}-${env:PACKER_BUILD_NAME}-icserver.log") | ||
} | ||
if (Test-Path "C:\ProgramData\chocolatey\logs\chocolatey.log") | ||
{ | ||
if ($PSCmdlet.ShouldProcess("chocolatey.log", "Backing up")) | ||
{ | ||
Copy-Item C:\ProgramData\chocolatey\logs\chocolatey.log $log_dir | ||
} | ||
} | ||
|
||
Get-ChildItem "C:\Windows\Logs\*.log" | ForEach { | ||
if ($PSCmdlet.ShouldProcess((Split-Path $_ -Leaf), "Backing up")) | ||
{ | ||
Copy-Item $_ $log_dir | ||
} | ||
} | ||
|
||
if (Test-Path "C:\Windows\Logs\icfirmware-*.log") | ||
Get-ChildItem "C:\Windows\Logs\*.txt" | ForEach { | ||
if ($PSCmdlet.ShouldProcess((Split-Path $_ -Leaf), "Backing up")) | ||
{ | ||
Copy-Item $_ $log_dir | ||
} | ||
} | ||
|
||
Start-Sleep 5 | ||
} | ||
end | ||
{ | ||
Copy-Item C:\Windows\Logs\icfirmware-*.log (Join-Path $log_dir "packer-build-${env:PACKER_BUILDER_TYPE}-${env:PACKER_BUILD_NAME}-icfirmware.log") | ||
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | ||
} | ||
|
||
Start-Sleep 5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<# # Documentation {{{ | ||
.Synopsis | ||
Installs .Net 3.5 | ||
#> # }}} | ||
[CmdletBinding(SupportsShouldProcess=$true)] | ||
Param( | ||
) | ||
begin | ||
{ | ||
Write-Output "Script started at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | ||
$Now = Get-Date -Format 'yyyyMMddHHmmss' | ||
} | ||
process | ||
{ | ||
function Show-Elapsed([Diagnostics.StopWatch] $watch) # {{{ | ||
{ | ||
$elapsed = '' | ||
if ($watch.Elapsed.Days -gt 0) { $elapsed += " $($watch.Elapsed.Days) days" } | ||
if ($watch.Elapsed.Hours -gt 0) { $elapsed += " $($watch.Elapsed.Hours) hours" } | ||
if ($watch.Elapsed.Minutes -gt 0) { $elapsed += " $($watch.Elapsed.Minutes) minutes" } | ||
if ($watch.Elapsed.Seconds -gt 0) { $elapsed += " $($watch.Elapsed.Seconds) seconds" } | ||
return $elapsed | ||
} # }}} | ||
|
||
# Prerequisites: {{{ | ||
# Prerequisite: Powershell 3 {{{2 | ||
if($PSVersionTable.PSVersion.Major -lt 3) | ||
{ | ||
Write-Error "Powershell version 3 or more recent is required" | ||
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | ||
Start-Sleep 2 | ||
exit 1 | ||
} | ||
# 2}}} | ||
# Prerequisites }}} | ||
|
||
# Checking for dotnet 4.5.2 | ||
$dotnet_info = Get-ItemProperty -Path 'HKLM:\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full' -ErrorAction SilentlyContinue | ||
if ($dotnet_info -eq $null -or $dotnet_info.Release -lt 379893) | ||
{ | ||
Write-Error "Failure while installing .Net 4.5.2" | ||
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | ||
Start-Sleep 5 | ||
exit 1 | ||
} | ||
} | ||
end | ||
{ | ||
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')" | ||
Start-Sleep 5 | ||
exit $LastExitCode | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$mgr = New-Object -ComObject Microsoft.Update.ServiceManager -Strict | ||
$mgr.ClientApplicationID = "packer" | ||
$mgr.RemoveService('7971f918-a847-4430-9279-4a52d1efe18d') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$mgr = New-Object -ComObject Microsoft.Update.ServiceManager -Strict | ||
$mgr.ClientApplicationID = "packer" | ||
$mgr.AddService2("7971f918-a847-4430-9279-4a52d1efe18d",7,"") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.