Skip to content

Commit

Permalink
Copy expand cd (#9)
Browse files Browse the repository at this point in the history
* Issue #3
- Added the concept of private functions.
- AWS S3 bucker support for Get-ISHPrerequisites and Set-ISHToolAntennaHouseLicense
- Some refactoring

* #3
Fixed small issues in the Publish-Module.ps1

* #7
- Added `Get-ISHCD` cmdlet
- Added `Expand-ISHCD` cmdlet

* #7 Small fix

* #7
- Optimized Publish automation
- Fixed bugs

* #7
- Improved the Get-ISHCD ListAvailable functionality
- Enhanced the README.MD

* Upgrade SDLDevTools to version 0.3
  • Loading branch information
Sarafian authored Feb 6, 2017
1 parent ecb982e commit bdf71e0
Show file tree
Hide file tree
Showing 19 changed files with 384 additions and 71 deletions.
33 changes: 19 additions & 14 deletions Automation/Pester/Test-SDLHeaders.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,28 @@
# limitations under the License.
#>

$sourcePath=Resolve-Path "$PSScriptRoot\..\.."
$repositoryPath=Resolve-Path "$PSScriptRoot\..\.."
$modulePath=Resolve-Path "$repositoryPath\Tools\Modules"

Import-Module "$sourcePath\Tools\Modules\SDLDevTools" -Force
Import-Module "$modulePath\SDLDevTools" -Force

# Must convert to array of hash to drive the It -Testcases parameter
$filesToValidate=@()
Get-ChildItem -Path $sourcePath -Recurse -File -Exclude ".git" |Select-Object Name,FullName|ForEach-Object {
$hash=@{
Name=$_.Name
FullName=$_.FullName
}
$filesToValidate+=$hash
}
$reportToValidate=@()
Test-SDLOpenSourceHeader -ExcludeFolder ".git" -FolderPath $repositoryPath -PassThru | ForEach-Object {
$hash=@{}
$hash.FilePath=$_.FilePath
$hash.Format=$_.Format
$hash.Error=$_.Error
$hash.IsValid=$_.IsValid

$reportToValidate+=$hash
}
Describe "Verify open source headers" {
It "Test-SDLOpenSourceHeader <Name>" -TestCases $filesToValidate {
param ($Name,$FullName)
Test-SDLOpenSourceHeader -FilePath $FullName
It "Test-SDLOpenSourceHeader <FilePath>" -TestCases $reportToValidate {
param ($FilePath,$Format,$Error,$IsValid)
if(-not $IsValid)
{
Write-Warning "$Error in $FilePath"
}
$IsValid | Should BeExactly $true
}
}
76 changes: 37 additions & 39 deletions Automation/Publish-Module.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ param(
[switch]$ISH13=$false
#>
)

$moduleNamesToPublish=@()
switch ($PSCmdlet.ParameterSetName)
{
Expand Down Expand Up @@ -157,50 +156,49 @@ foreach($moduleName in $moduleNamesToPublish)
}
#endregion

if($shouldTryPublish)
{
#region manifest
Write-Debug "Generating manifest"
#region manifest
Write-Debug "Generating manifest"

Import-Module $psm1Path -Force
$exportedNames=Get-Command -Module $moduleName | Select-Object -ExcludeProperty Name

$psm1Name=$moduleName+".psm1"
$psd1Path=Join-Path $modulePath "$moduleName.psd1"
$guid="c1e7cbac-9e47-4906-8281-5f16471d7ccd"
$hash=@{
"Author"="SDL plc"
"CompanyName" = "SDL plc"
"Copyright"="SDL plc. All rights reserved."
"RootModule"=$psm1Name
"Description"="Prerequisite automation module for SDL Knowledge Center Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)"
"ModuleVersion"=$sourceVersion
"Path"=$psd1Path
"LicenseUri"='https://github.com/Sarafian/ISHServer/blob/master/LICENSE'
"ProjectUri"= 'https://github.com/Sarafian/ISHServer/'
"ReleaseNotes"= 'https://github.com/Sarafian/ISHServer/blob/master/CHANGELOG.md'
"CmdletsToExport" = $exportedNames
"FunctionsToExport" = $exportedNames
Import-Module $psm1Path -Force
$exportedNames=Get-Command -Module $moduleName | Select-Object -ExcludeProperty Name
$psm1Name=$moduleName+".psm1"
$psd1Path=Join-Path $modulePath "$moduleName.psd1"
$guid="c1e7cbac-9e47-4906-8281-5f16471d7ccd"
$hash=@{
"Author"="SDL plc"
"CompanyName" = "SDL plc"
"Copyright"="SDL plc. All rights reserved."
"RootModule"=$psm1Name
"Description"="Prerequisite automation module for SDL Knowledge Center Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)"
"ModuleVersion"=$sourceVersion
"Path"=$psd1Path
"LicenseUri"='https://github.com/Sarafian/ISHServer/blob/master/LICENSE'
"ProjectUri"= 'https://github.com/Sarafian/ISHServer/'
"ReleaseNotes"= 'https://github.com/Sarafian/ISHServer/blob/master/CHANGELOG.md'
"CmdletsToExport" = $exportedNames
"FunctionsToExport" = $exportedNames
}
switch ($moduleName)
{
'ISHServer.12' {
$hash.Description="Prerequisite automation module for SDL Knowledge Center 2016 Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)"
$hash.Guid="469894fc-530e-47dd-9158-ed5148815712"
break
}
switch ($moduleName)
{
'ISHServer.12' {
$hash.Description="Prerequisite automation module for SDL Knowledge Center 2016 Content Manager 12.0.* (LiveContent Architect, Trisoft InfoShare)"
$hash.Guid="469894fc-530e-47dd-9158-ed5148815712"
break
}
'ISHServer.13' {
$hash.Description="Prerequisite automation module for SDL Knowledge Center Content Manager 13.0.* (LiveContent Architect, Trisoft InfoShare)"
$hash.Guid="c73125ea-0914-4a1c-958b-05eccd6c2c29"
break
}
'ISHServer.13' {
$hash.Description="Prerequisite automation module for SDL Knowledge Center Content Manager 13.0.* (LiveContent Architect, Trisoft InfoShare)"
$hash.Guid="c73125ea-0914-4a1c-958b-05eccd6c2c29"
break
}
}

New-ModuleManifest @hash
New-ModuleManifest @hash

Write-Verbose "Generated manifest"
#endregion
Write-Verbose "Generated manifest"
#endregion

if($shouldTryPublish)
{
#region publish
Write-Debug "Publishing $moduleName"
Write-Progress -Activity $progressActivity -Status "Publishing..."
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
- `Get-ISHPrerequisites` now supports S3 buckets as source.
- `Set-ISHToolAntennaHouseLicense` now supports S3 buckets as source.
- `Test-RunningAsElevated` is now a private function in the module.
- New `Get-ISHCD` cmdlet:
- Downloads a CD from FTP or AWS S3 bucket.
- Returns the available CDs
- New `Expand-ISHCD` cmdlet expands a CD into `C:\ISHCD`.

**1.0**

Expand Down
24 changes: 20 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ A PowerShell module to help automate installation of prerequisites for **Knowled

The module requires elevated privileges for most of its cmdlets.

## Prerequisite and CD sources

The module can retrieve files from the following type of sources:

- FTP.
- Amazon Web Services S3 bucket.

For each different type of credentials are required.

## Preparation

To test if the operating system is compatible execute first `Test-ISHServerCompliance`.
Expand Down Expand Up @@ -38,10 +47,7 @@ NETFramework2013_4.5_MicrosoftVisualC++Redistributable_(vcredist_x64).exe
```

If you want to manually make the files available to the module then copy them to the location provided by `Get-ISHServerFolderPath`.
As an alternative, the `Get-ISHPrerequisites` cmdlet offers the option to download the files from a known location and will take care of everything.
Current options are:

- FTP. Just provide the ftp hostname, a relative folder path containing the above files and the credentials. e.g. `Get-ISHPrerequisites -Credential $Credential -FTPFolder $folderPath -FTPHost $host`.
As an alternative, the `Get-ISHPrerequisites` cmdlet offers the option to download the files will take care of everything.

## Installing and configuring

Expand All @@ -50,6 +56,16 @@ The module is structured in manner that represents the steps described in the pr
Understanding the prerequisites and how to configure them will be helpful but it is not a requirement.
An example of how to use the sequence the installation and configuration is available in [ISHBootstrap](https://github.com/Sarafian/ISHBootstrap).

## CD Management

ISHServer offers two cmdlets to download and expand the ISHCD. **Notice that it will not install a CD!**
- `Get-ISHCD` can download a CD or show the ones already downloaded and expanded.
- `Expand-ISHCD` will expand the CD.

The target path is always `C:\ISHCD\X.0.Z` where `X` is the major version and `Y` the revision.
- For `12.0.1` it's `C:\ISHCD\12.0.1`
- For `12.0.3` it's `C:\ISHCD\12.0.3`

## Maintenance

For installation and maintenance reasons, the module offers a couple of general purpose cmdlets:
Expand Down
103 changes: 103 additions & 0 deletions Source/Modules/ISHServer/Expand-ISHCD.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<#
# Copyright (c) 2014 All Rights Reserved by the SDL Group.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#>

function Expand-ISHCD
{
[CmdletBinding()]
param(
[Parameter(Mandatory=$true)]
[ValidatePattern(".+\.[0-9]+\.0\.[0-9]+\.[0-9]+.*\.exe")]
[string]$FileName,
[Parameter(Mandatory=$false)]
[switch]$Force=$false
)

begin
{
. $PSScriptRoot\Private\Test-RunningAsElevated.ps1
Test-RunningAsElevated -StopCallerPSCmdlet $PSCmdlet

. $PSScriptRoot\Get-ISHServerFolderPath.ps1
. $PSScriptRoot\Get-ISHCD.ps1
}

process
{
$ishCDPath="C:\IshCD"

$localPath=Get-ISHServerFolderPath
$cdPath=Join-Path $localPath $FileName
if(-not (Test-Path $cdPath))
{
Write-Error "$FileName doesn't exist."
return
}
$regEx=".+\.(?<Major>[0-9]+)\.0\.(?<Build>[0-9]+)\.(?<Revision>[0-9]+).+\.exe"
if($FileName -notmatch $regEx)
{
Write-Error "$FileName has unknown format."
return
}

$major=[int]$Matches["Major"]
$build=[int]$Matches["Build"]
$revision=[int]$Matches["Revision"]

$ishVersion="$($major).0.$($revision)"
Write-Debug "ishVersion=$ishVersion"
$expandPath="$ishCDPath\$ishVersion"
Write-Debug "expandPath=$expandPath"

if($major -lt 12)
{
Write-Error "Only CD's with major version 12 or higher are supported."
}
if(Get-ISHCD -ListAvailable |Where-Object -Property Name -EQ $FileName|Where-Object -Property IsExpanded -EQ $true)
{
if(-not $Force)
{
Write-Warning "$Filename is already expanded. Skipping ..."
return
}
}

if($major -eq "12")
{
#CD is compressed with WinRar
$arguments=@("-d$expandPath","-s")
}
else
{
#CD is compressed with 7Zip
$arguments=@(
"-y"
"-gm2"
"-InstallPath=`"$($expandPath.Replace('\','\\'))`""
)
}
Write-Debug "arguments=$($arguments -join " ")"

Write-Debug "Unzipping $cdPath in $expandPath"
Start-Process $cdPath -ArgumentList $arguments -Wait
Write-Verbose "Unzipped $cdPath in $expandPath"

}

end
{

}
}
Loading

0 comments on commit bdf71e0

Please sign in to comment.