Skip to content

Commit

Permalink
Merge branch 'release/3.0.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Gildas Cherruel committed Feb 10, 2016
2 parents 65c4cfd + 287a3bf commit 67b138d
Show file tree
Hide file tree
Showing 29 changed files with 958 additions and 247 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ boxes/
boxes
*.box

# test box
templates/test/

# temp folder
tmp/

Expand All @@ -21,6 +24,9 @@ log/
# vagrant folder
.vagrant/

# Bundler folder
.bundle/

# .GitEye
/.project

Expand Down
228 changes: 167 additions & 61 deletions Rakefile

Large diffs are not rendered by default.

100 changes: 69 additions & 31 deletions scripts/Backup-Logs.ps1
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
52 changes: 52 additions & 0 deletions scripts/check-dotnet452.ps1
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
}
110 changes: 89 additions & 21 deletions scripts/check-icserver.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -169,39 +169,107 @@ function Test-MsiExecMutex # {{{
}
} # }}}

try
{
#$MSI_available=Test-MSIExecMutex -MsiExecWaitTime $(New-TimeSpan -Minutes 5)
#if (-not $MSI_available)
#{
# Write-Output "IC Server installation is not finished yet. This is bad news..."
# exit 1618
#}

$watch = [Diagnostics.StopWatch]::StartNew()
do
{
Start-Sleep $Sleep
$msiexec_count = @(Get-Process | where ProcessName -eq 'msiexec').Count
$watch = [Diagnostics.StopWatch]::StartNew()
do
{
Start-Sleep $Sleep
$msiexec_count = @(Get-Process | where ProcessName -eq 'msiexec').Count
$elapsed = Show-Elapsed($watch)
Write-Output "Found ${msiexec_count} MSI installers running after $elapsed"
}
while ($msiexec_count -gt $RunningMsiAllowed)
$watch.Stop()
$elapsed = Show-Elapsed($watch)
Write-Output "Found ${msiexec_count} MSI installers running after $elapsed"
}
while ($msiexec_count -gt $RunningMsiAllowed)
$watch.Stop()
$elapsed = Show-Elapsed($watch)
Write-Output "No more MSI installers running after $elapsed"
Write-Output "No more MSI installers running after $elapsed"

if (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "${Product}.*")
if (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Where-Object DisplayName -match "${Product}.*")
{
Write-Output "$Product is installed"
}
else
{
Write-Output "Failed to install $Product"
Write-Output "Manually backing up logs"

if (Test-Path $env:USERPROFILE/share-log.info)
{
Write-Output "$Product is installed"
$ShareArgs = @{ PSProvider = 'FileSystem'; ErrorAction = 'Stop' }
$ShareInfo = Get-Content $env:USERPROFILE/share-log.info -Raw | ConvertFrom-Json

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
{
#TODO: Should we return values or raise exceptions?
Write-Output "Failed to install $Product (Error: $LastExitCode)"
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
}

$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:\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
}
}

Get-ChildItem "C:\Windows\Logs\*.txt" | ForEach {
if ($PSCmdlet.ShouldProcess((Split-Path $_ -Leaf), "Backing up"))
{
Copy-Item $_ $log_dir
}
}
#Write-Output "Backing up logs"
#Backup-Logs.ps1
exit 2
}
}
finally
{
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
Start-Sleep 2
}
}
end
{
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
Start-Sleep 2
exit $LastExitCode
}
3 changes: 3 additions & 0 deletions scripts/disable-update.ps1
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')
3 changes: 3 additions & 0 deletions scripts/enable-update.ps1
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,"")
53 changes: 49 additions & 4 deletions scripts/install-dotnet35.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,71 @@ process

if ((Get-WindowsFeature Net-Framework-Core -Verbose:$false).InstallState -ne 'Installed')
{
if (Get-Hotfix -id 2966828 -ErrorAction SilentlyContinue)
{
Write-Output "KB 2966828 was installed, we need to uninstall it"

$install='NDPFixit-KB3005628-X64.exe'
$source_url="http://download.microsoft.com/download/8/0/8/80894270-D665-4E7A-8A2C-814373FC25C1/$install"
$dest=Join-Path $env:TEMP $install

Write-Output "Downloading KB 3005628"
#Start-BitsTransfer -Source $source_url -Destination $dest -ErrorAction Stop
(New-Object System.Net.WebClient).DownloadFile($source_url, $dest)

#& ${env:TEMP}\NDPFixit-KB3005628-X64.exe /Log C:\Windows\Logs\KB-3005628.log
& ${env:TEMP}\NDPFixit-KB3005628-X64.exe
}
Write-Output "Installing .Net 3.5"
$watch = [Diagnostics.StopWatch]::StartNew()
if ($PSCmdlet.ShouldProcess('.Net 3.5', "Running msiexec /install"))
{
Install-WindowsFeature -Name Net-Framework-Core
if (! $?)
$parms = @{}
$dvd_drives = Get-WmiObject Win32_LogicalDisk -Filter 'DriveType=5' | Select -ExpandProperty DeviceID
foreach ($_ in $dvd_drives)
{
$sources = (Join-Path $_ (Join-Path 'sources' 'sxs'))
if (Test-Path $sources)
{
$parms['Source'] = $sources
Write-Output "Using $sources to install .Net"
break
}
}

$results = Install-WindowsFeature -Name Net-Framework-Core -LogPath C:\Windows\Logs\dotnet-3.5.log @parms -Verbose
if (! $results.Success)
{
Write-Error "ERROR $LastExitCode while installing .Net 3.5"
Write-Error "Failure while installing .Net 3.5, exit code: $($results.ExitCode)"
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
Start-Sleep 10
exit $LastExitCode
exit 1
}
}
$watch.Stop()
$elapsed = Show-Elapsed($watch)
Write-Output ".Net 3.5 installed successfully in $elapsed!"
Write-Output $results.FeatureResult
switch($results.RestartNeeded)
{
[Microsoft.Windows.ServerManager.Commands.RestartState]::Yes
{
Write-Warning "The system will need to be restarted to be able to use the new features"
}
[Microsoft.Windows.ServerManager.Commands.RestartState]::Maybe
{
Write-Warning "The system might need to be restarted to be able to use the new features"
}
[Microsoft.Windows.ServerManager.Commands.RestartState]::No
{
Write-Output "The system does not need to be restarted to be able to use the new features"
}
}
}
}
end
{
Write-Output "Script ended at $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss')"
Start-Sleep 5
exit 0
}
Loading

0 comments on commit 67b138d

Please sign in to comment.