Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
- Pure WindowsServerCore image works
- SQLServer2014Express doesn't work. Runs out of memory
GH-54: Not working yet
GH-55: Not working yet
  • Loading branch information
Sarafian committed Mar 3, 2017
1 parent 20ca234 commit 068d52c
Show file tree
Hide file tree
Showing 48 changed files with 2,091 additions and 194 deletions.
2 changes: 2 additions & 0 deletions Source/.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*/Packer
**/*.box
68 changes: 68 additions & 0 deletions Source/Bake-ISHFromAWSS3.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#requires -runasadministrator

param(
[Parameter(Mandatory=$true,ParameterSetName="Default")]
[Parameter(Mandatory=$true,ParameterSetName="AWS Credential")]
[ValidateSet("12.0.3","12.0.4","13.0.0")]
[string]$ISHVersion,
[Parameter(Mandatory=$false,ParameterSetName="Default")]
[Parameter(Mandatory=$false,ParameterSetName="AWS Credential")]
[string]$MockConnectionString=$null,
[Parameter(Mandatory=$true,ParameterSetName="AWS Credential")]
[string]$AccessKey,
[Parameter(Mandatory=$true,ParameterSetName="AWS Credential")]
[string]$SecretKey
)

if ($PSBoundParameters['Debug']) {
$DebugPreference = 'Continue'
}
# Normalize to null incase the packer and container feed the parameter with empty
if($MockConnectionString -eq "")
{
$MockConnectionString=""
}

$buildersPath=Join-Path $PSScriptRoot Builders

switch($ISHVersion) {
'12.0.3' {
$hash=@{
BucketName="sct-released"
ISHServerFolder="InfoShare/12.0/PreRequisites"
ISHCDFolder="InfoShare/12.0/"
ISHCDFileName="20170125.CD.InfoShare.12.0.3725.3.Trisoft-DITA-OT.exe"
}
}
'12.0.4' {
$hash=@{
BucketName="sct-released"
ISHServerFolder="InfoShare/12.0/PreRequisites"
ISHCDFolder="InfoShare/12.0/"
ISHCDFileName="20170302.CD.InfoShare.12.0.3902.4.Prod.Trisoft-DITA-OT.exe"
}
}
'13.0.0' {
$hash=@{
BucketName="sct-notreleased"
ISHServerFolder="InfoShare/13.0/PreRequisites"
ISHCDFolder="InfoShare/13.0/"
ISHCDFileName="20170202.CD.InfoShare.13.0.2602.0.Test.Trisoft-DITA-OT.exe"
}
}
}

if($PSCmdlet.ParameterSetName -eq "AWS Credential")
{
$hash.AccessKey=$AccessKey
$hash.SecretKey=$SecretKey
}

$hash.ConnectionString=$MockConnectionString

& $buildersPath\Prerequisites\Install-Prerequisites.ps1 -NuGet
$prerequisites=& $buildersPath\Prerequisites\New-PrerequisitesList.ps1 -ISHVersion $ishVersion -AWS
& $buildersPath\Prerequisites\Install-Prerequisites.ps1 -Prerequisites $prerequisites

& $buildersPath\Initialize-ISHImage.ps1 @hash -ISHVersion $ishVersion

19 changes: 13 additions & 6 deletions Source/Builders/Database/Install-MockDatabase.ps1
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
param(
param(
[Parameter(Mandatory=$true,ParameterSetName="Database")]
[ValidateSet("12.0.3","12.0.4","13.0.0")]
[string]$ISHVersion
Expand All @@ -9,12 +9,19 @@ $cmdletsPaths="$PSScriptRoot\..\..\Cmdlets"
. "$cmdletsPaths\Helpers\Write-Separator.ps1"
Write-Separator -Invocation $MyInvocation -Header

$ishServerVersion=($ISHVersion -split "\.")[0]
$sql_express_download_url="https://download.microsoft.com/download/2/A/5/2A5260C3-4143-47D8-9823-E91BB0121F94/SQLEXPR_x64_ENU.exe"
$sqlExpressPath=Join-Path $PSScriptRoot "sqlexpress.exe"
$setupPath=Join-Path $PSScriptRoot "setup\setup.exe"
Write-Host "Downloading"
Invoke-WebRequest -Uri $sql_express_download_url -OutFile $sqlExpressPath

$packages=@{
Name="mssqlserver2014express"
}
Write-Host "Extracting"
Start-Process -Wait -FilePath $sqlExpressPath -ArgumentList /qs, /x:setup

& $PSScriptRoot\..\Prerequisites\Install-Prerequisites.ps1 -Chocolatey $packages
Write-Host "Installing"
& $setupPath /q /ACTION=Install /INSTANCENAME=SQLEXPRESS /FEATURES=SQLEngine /UPDATEENABLED=0 /SQLSVCACCOUNT='NT AUTHORITY\System' /SQLSYSADMINACCOUNTS='BUILTIN\ADMINISTRATORS' /TCPENABLED=1 /NPENABLED=0 /IACCEPTSQLSERVERLICENSETERMS

Write-Host "Cleaning"
Remove-Item -Recurse -Force $sqlExpressPath, $setupPath

Write-Separator -Invocation $MyInvocation -Footer
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
param(
[Parameter(Mandatory=$true)]
[ValidateSet("12.0.3","12.0.4","13.0.0")]
[string]$ISHVersion,
[Parameter(Mandatory=$false)]
[switch]$DevelopFriendly=$false
[string]$ISHVersion
)

$cmdletsPaths="$PSScriptRoot\..\..\Cmdlets"
Expand All @@ -20,18 +18,13 @@ $sqlServerItem=Get-ChildItem -Path "${env:ProgramFiles(x86)}\Microsoft SQL Serve
$sqlServerPath=$sqlServerItem |Select-Object -ExpandProperty FullName
$sqlServerMajorVersion=$sqlServerItem.Name.Substring(0,$sqlServerItem.Name.Length-1)

#region 1. [DEVELOPFRIENDLY] Enable TCP remote connections and mixed mode authentication
if($DevelopFriendly)
{
& ..\DevelopFriendly\Enable-SQLServerMixedModeTCP.ps1
}
#endregion
Push-Location -StackName "SQL"

#region 2. Import SQLPS module
#region 1. Import SQLPS module

# Test if SQLPS module is already available.
# Normally the installer modifies the system variables $env:PSModulePath but for them to take effect a restart is needed.
Write-Information "Importing module SQLPS"
Write-Host "Importing module SQLPS"
if(-not (Get-Module SQLPS -ListAvailable))
{
Import-Module "$sqlServerPath\Tools\PowerShell\Modules\SQLPS\SQLPS.PSD1" -Force
Expand All @@ -40,38 +33,24 @@ else
{
Import-Module SQLPS -Force
}

Get-ChildItem |Where-Object -Property Description -EQ "SQL Server Database Engine"|Select-Object -First 1|Get-ChildItem|Get-ChildItem|Push-Location
$cmd="select serverproperty('InstanceDefaultDataPath') AS InstanceDefaultDataPath,serverproperty('InstanceDefaultLogPath') AS InstanceDefaultLogPath"
$result=Invoke-Sqlcmd -Query $cmd
$sqlServerDataPath=$result.InstanceDefaultDataPath.TrimEnd("\")
$sqlServerLogPath=$result.InstanceDefaultLogPath.TrimEnd("\")
#endregion

#region 3. [DEVELOPFRIENDLY] Alter sa password

if($DevelopFriendly)
{
$blockName="[DEVELOPFRIENDLY][SQL Server Express]:Enabling sa account"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName

$sa_password="Password123"
$sqlAlterSACmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;"

Invoke-Sqlcmd -Query $sqlAlterSACmd -ServerInstance ".\SQLEXPRESS"
Set-Location c:
Write-Warning "[DEVELOPFRIENDLY][SQL Server Express]:Enabled sa account"
}

#endregion

#region 4. Restore database
#region 2. Restore database
$blockName="Restoring ISH database"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

$ishCDPath=Get-ISHCD -ListAvailable |
Where-Object -Property Major -EQ $ishServerVersion |
Where-Object -Property Revision -EQ $ishRevision|
Where-Object -Property IsExpanded -EQ $true |
Select-Object -ExpandProperty ExpandedPath

$ishCDPath
$segments=@(
$ishCDPath
"Database"
Expand All @@ -80,19 +59,20 @@ $segments=@(
"20151116.InfoShareEmpty-12.0.0-sqlserver2012.isource.InfoShare-OasisDita.1.2.bak"
)
$infoShareBakPath=$segments -join '\'
$sqlServerDataPath="C:\Program Files\Microsoft SQL Server\MSSQL$sqlServerMajorVersion.SQLEXPRESS\MSSQL\DATA"

$dbName="InfoShare"
$sqlRestoreDBCmd=@"
USE [master]
if db_id('$dbName') is null
BEGIN
RESTORE DATABASE [$dbName] FROM DISK = N'$infoShareBakPath' WITH FILE = 1, MOVE N'$dbName' TO N'$sqlServerDataPath\$dbName.mdf', MOVE N'$($dbName)_Log' TO N'$sqlServerDataPath\$($dbName)_log.ldf', NOUNLOAD, STATS = 5
RESTORE DATABASE [$dbName] FROM DISK = N'$infoShareBakPath' WITH FILE = 1, MOVE N'$dbName' TO N'$sqlServerDataPath\$dbName.mdf', MOVE N'$($dbName)_Log' TO N'$sqlServerLogPath\$($dbName)_log.ldf', NOUNLOAD, STATS = 5
END
GO
"@
Invoke-Sqlcmd -Query $sqlRestoreDBCmd -ServerInstance ".\SQLEXPRESS"

Set-Location c:
Invoke-Sqlcmd -Query $sqlRestoreDBCmd

Pop-Location -StackName "SQL"

#endregion

Expand Down
6 changes: 3 additions & 3 deletions Source/Builders/Database/Start-MockDatabase.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ $cmdletsPaths="$PSScriptRoot\..\..\Cmdlets"
. "$cmdletsPaths\Helpers\Write-Separator.ps1"
Write-Separator -Invocation $MyInvocation -Header

Write-Information "Starting SQL Server service"
Write-Host "Starting SQL Server service"

$sqlExpressServiceName="MSSQL`$SQLEXPRESS"
Start-Service -Name $sqlExpressServiceName

Write-Information "Importing module SQLPS"
Write-Host "Importing module SQLPS"
if(-not (Get-Module SQLPS -ListAvailable))
{
$sqlServerItem=Get-ChildItem -Path "${env:ProgramFiles(x86)}\Microsoft SQL Server" -Filter "*0" |Sort-Object -Descending @{expression={[int]$_.Name}}| Select-Object -First 1
Expand All @@ -35,7 +35,7 @@ else
{
throw "Could not parse connection string"
}
Write-Information "[DEMO][SQL Server Express]:Configuring $OSUserSqlUser account"
Write-Host "[DEMO][SQL Server Express]:Configuring $OSUserSqlUser account"

$sqlCmd = @"
USE [master]
Expand Down
13 changes: 0 additions & 13 deletions Source/Builders/Database/Stop-MockDatabase.ps1

This file was deleted.

18 changes: 0 additions & 18 deletions Source/Builders/Database/Uninstall-MockDatabase.ps1

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ $cmdletsPaths="$PSScriptRoot\..\..\Cmdlets"
. "$cmdletsPaths\Helpers\Write-Separator.ps1"
Write-Separator -Invocation $MyInvocation -Header

Write-Information "[DEVELOPFRIENDLY][SQL Server Express]:Enabling Mixed mode authentication and TCP protocol for external connections"
Write-Host "[DEVELOPFRIENDLY][SQL Server Express]:Enabling Mixed mode authentication and TCP protocol for external connections"

$sqlExpressServiceName="MSSQL`$SQLEXPRESS"
Stop-Service -Name $sqlExpressServiceName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ $cmdletsPaths="$PSScriptRoot\..\..\Cmdlets"
Write-Separator -Invocation $MyInvocation -Header

$blockName="[DEVELOPFRIENDLY][Windows Server]:Installing IIS Management Console (inetmgr.exe)"
Write-Information $blockName
Write-Host $blockName

Get-WindowsFeature -Name Web-Mgmt-Console|Install-WindowsFeature

Expand Down
32 changes: 22 additions & 10 deletions Source/Builders/Initialize-ISH.Instance.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ $useMockedDatabaseAsDemo=$PSCmdlet.ParameterSetName -eq "Demo Database"

$blockName="Importing certificate"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

$certificate=Import-PfxCertificate -Password $PFXCertificatePassword -FilePath $PFXCertificatePath -Exportable -CertStoreLocation "Cert:\LocalMachine\My"
Import-Module WebAdministration
Expand All @@ -48,7 +48,7 @@ Pop-Location -StackName "IIS"

$blockName="Getting deployment information"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

$softwareVersion=Get-ISHDeployment |Select-Object -First 1 -ExpandProperty SoftwareVersion
$ishVersion="$($softwareVersion.Major).0.$($softwareVersion.Revision)"
Expand Down Expand Up @@ -91,12 +91,24 @@ $trisoftInfoShareAuthorApplication=$applications|Where-Object -Property Name -EQ
#region 4. Initialize OSUser
$blockName="Initializing osuser"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

if(-not (Get-LocalUser -Name $osUserName -ErrorAction SilentlyContinue))
if(Get-Module Microsoft.PowerShell.LocalAccounts -ListAvailable)
{
New-LocalUser -Name $osUserName -Password $OsUserCredentials.Password -AccountNeverExpires -PasswordNeverExpires
if(-not (Get-LocalUser -Name $osUserName -ErrorAction SilentlyContinue))
{
New-LocalUser -Name $osUserName -Password $OsUserCredentials.Password -AccountNeverExpires -PasswordNeverExpires
}
}
else
{
NET USER $osUserName $osUserPassword /ADD
# Uncheck 'User must change password'
$user = [adsi]"WinNT://$env:computername/$osUserName"
$user.UserFlags.value = $user.UserFlags.value -bor 0x10000
$user.CommitChanges()
}

$arguments=@(
"-Command"
"Initialize-ISHRegional"
Expand All @@ -121,7 +133,7 @@ if($useMockedDatabaseAsDemo)

$blockName="Initializing process identity"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

$ishAppPools|ForEach-Object {
$_.ProcessModel.UserName = $osUserName
Expand Down Expand Up @@ -150,7 +162,7 @@ if(-not $useMockedDatabaseAsDemo)
{
$blockName="Setting database connection"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

Set-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Trisoft\Tridk\TridkApp\InfoShareAuthor'-Name "Connect" -Value $ConnectionString
Set-ItemProperty -Path 'HKLM:\SOFTWARE\WOW6432Node\Trisoft\Tridk\TridkApp\InfoShareAuthor'-Name "ComponentName" -Value $DbType
Expand All @@ -162,7 +174,7 @@ if(-not $useMockedDatabaseAsDemo)
#region 7. Hard replace files
$blockName="Replacing mock input parameters"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

if($HostName)
{
Expand Down Expand Up @@ -245,7 +257,7 @@ Write-Verbose "Replacement matrix is:"
$foldersToScan |ForEach-Object {
$blockName="Replacing files in $_"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

$filePaths=Get-ChildItem -Path $_ -Include $extensions -Recurse -File|Select-Object -ExpandProperty FullName
$filePaths|ForEach-Object {
Expand Down Expand Up @@ -418,7 +430,7 @@ C:\IshCD\12.0.1\20160815.CD.InfoShare.12.0.3215.1.Trisoft-DITA-OT\Websites\Autho

$blockName="Starting IIS application pools"
Write-Progress @scriptProgress -Status $blockName
Write-Information $blockName
Write-Host $blockName

$ishAppPools| Start-WebAppPool
#endregion
Expand Down
Loading

0 comments on commit 068d52c

Please sign in to comment.