-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #82 from sdl/develop
Release
- Loading branch information
Showing
14 changed files
with
337 additions
and
122 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
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
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,103 +1,122 @@ | ||
param( | ||
[Parameter(Mandatory=$true,ParameterSet="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSet="Internal Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="Internal Database")] | ||
[string]$OsUserName, | ||
[Parameter(Mandatory=$true,ParameterSet="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSet="Internal Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="Internal Database")] | ||
[string]$OsUserPassword, | ||
[Parameter(Mandatory=$true,ParameterSet="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSet="Internal Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="Internal Database")] | ||
[string]$PFXCertificatePath, | ||
[Parameter(Mandatory=$true,ParameterSet="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSet="Internal Database")] | ||
[securestring]$PFXCertificatePassword, | ||
[Parameter(Mandatory=$false,ParameterSet="External Database")] | ||
[Parameter(Mandatory=$false,ParameterSet="Internal Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="Internal Database")] | ||
[string]$PFXCertificatePassword, | ||
[Parameter(Mandatory=$false,ParameterSetName="External Database")] | ||
[Parameter(Mandatory=$false,ParameterSetName="Internal Database")] | ||
[string]$HostName=$null, | ||
[Parameter(Mandatory=$true,ParameterSet="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="External Database")] | ||
[string]$ConnectionString, | ||
[Parameter(Mandatory=$true,ParameterSet="External Database")] | ||
[Parameter(Mandatory=$true,ParameterSetName="External Database")] | ||
[ValidateSet("sqlserver2014","oracle")] | ||
[string]$DBType, | ||
[Parameter(Mandatory=$false,ParameterSet="Internal Database")] | ||
[Parameter(Mandatory=$false,ParameterSetName="Internal Database")] | ||
[string]$sa_password, | ||
[Parameter(Mandatory=$false,ParameterSet="Internal Database")] | ||
[Parameter(Mandatory=$false,ParameterSetName="Internal Database")] | ||
[string]$ACCEPT_EULA, | ||
[Parameter(Mandatory=$false,ParameterSet="External Database")] | ||
[Parameter(Mandatory=$false,ParameterSet="Internal Database")] | ||
[Parameter(Mandatory=$false,ParameterSetName="External Database")] | ||
[Parameter(Mandatory=$false,ParameterSetName="Internal Database")] | ||
[switch]$Loop=$false | ||
) | ||
|
||
if ($PSBoundParameters['Debug']) { | ||
$DebugPreference = 'Continue' | ||
} | ||
|
||
$buildersPath=Join-Path $PSScriptRoot "..\Builders" | ||
$firstRunPath=Join-Path $env:ProgramData "ISHDocker" | ||
|
||
$osUserCredentials=New-Object System.Management.Automation.PSCredential($OsUserName, (ConvertTo-SecureString -String $OsUserPassword -AsPlainText -Force)) | ||
$pfxCertificateSecurePassword=ConvertTo-SecureString -String $PFXCertificatePassword -AsPlainText -Force | ||
if(-not (Test-Path -Path $firstRunPath)) | ||
{ | ||
Write-Host "[DockerHost]Initializing container" | ||
|
||
$hash=@{ | ||
OsUserCredentials=$osUserCredentials | ||
PFXCertificatePath=$PFXCertificatePath | ||
PFXCertificatePassword=$pfxCertificateSecurePassword | ||
} | ||
$buildersPath=Join-Path $PSScriptRoot "..\Builders" | ||
|
||
if($HostName) | ||
{ | ||
$hash.HostName=$HostName | ||
} | ||
$osUserCredentials=New-Object System.Management.Automation.PSCredential($OsUserName, (ConvertTo-SecureString -String $OsUserPassword -AsPlainText -Force)) | ||
$osUserCredentials=Get-ISHNormalizedCredential -Credentials $osUserCredentials | ||
$pfxCertificateSecurePassword=ConvertTo-SecureString -String $PFXCertificatePassword -AsPlainText -Force | ||
|
||
switch ($PSCmdlet.ParameterSetName) | ||
{ | ||
'External Database' { | ||
$hash.ConnectionString=$ConnectionString | ||
$hash.DbType=$DBType | ||
$hash=@{ | ||
OsUserCredentials=$osUserCredentials | ||
PFXCertificatePath=$PFXCertificatePath | ||
PFXCertificatePassword=$pfxCertificateSecurePassword | ||
} | ||
'Internal Database' { | ||
$hash=@{ | ||
} | ||
& .\start -sa_password $sa_password -ACCEPT_EULA $ACCEPT_EULA -attach_dbs $attach_dbs | ||
|
||
if($HostName) | ||
{ | ||
$hash.HostName=$HostName | ||
} | ||
} | ||
|
||
if($PSCmdlet.ParameterSetName -eq "Internal Database") | ||
{ | ||
# Doing part of the https://github.com/Sarafian/Docker/blob/master/Source/mssql2014-server-windows-express/start.ps1 | ||
switch ($PSCmdlet.ParameterSetName) | ||
{ | ||
'External Database' { | ||
$hash.ConnectionString=$ConnectionString | ||
$hash.DbType=$DBType | ||
} | ||
'Internal Database' { | ||
Write-Host "[DockerHost]Starting internal database" | ||
# Doing part of the https://github.com/Sarafian/Docker/blob/master/Source/mssql2014-server-windows-express/start.ps1 | ||
|
||
if($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y"){ | ||
Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start." | ||
Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement." | ||
if($ACCEPT_EULA -ne "Y" -And $ACCEPT_EULA -ne "y"){ | ||
Write-Verbose "ERROR: You must accept the End User License Agreement before this container can start." | ||
Write-Verbose "Set the environment variable ACCEPT_EULA to 'Y' if you accept the agreement." | ||
|
||
exit 1 | ||
} | ||
exit 1 | ||
} | ||
|
||
Write-Verbose "Starting SQL Server" | ||
start-service MSSQL`$SQLEXPRESS | ||
|
||
Write-Verbose "Starting SQL Server" | ||
start-service MSSQL`$SQLEXPRESS | ||
if($sa_password -ne "_"){ | ||
Write-Verbose "Changing SA login credentials" | ||
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;" | ||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS" | ||
} | ||
|
||
if($sa_password -ne "_"){ | ||
Write-Verbose "Changing SA login credentials" | ||
$sqlcmd = "ALTER LOGIN sa with password=" +"'" + $sa_password + "'" + ";ALTER LOGIN sa ENABLE;" | ||
Invoke-Sqlcmd -Query $sqlcmd -ServerInstance ".\SQLEXPRESS" | ||
Write-Verbose "Started SQL Server." | ||
} | ||
} | ||
|
||
Write-Verbose "Started SQL Server." | ||
Write-Host "[DockerHost]Initializing deployment" | ||
& $buildersPath\Initialize-ISH.Instance.ps1 @hash -InContainer | ||
|
||
"Initialized" | Out-File -FilePath $firstRunPath -Force | ||
Write-Host "[DockerHost]Container ready" | ||
} | ||
else | ||
{ | ||
Write-Host "[DockerHost]Container already initialized" | ||
} | ||
|
||
& $buildersPath\Initialize-ISH.Instance.ps1 @hash | ||
|
||
if($Loop) | ||
{ | ||
$lastCheck = (Get-Date).AddSeconds(-2) | ||
$intervalSeconds=30 | ||
$lastCheck = (Get-Date).AddSeconds(-($intervalSeconds)) | ||
while ($true) { | ||
if($PSCmdlet.ParameterSetName -eq "Internal Database") | ||
{ | ||
Write-Host "Probing event log for MSSQL" | ||
Get-EventLog -LogName Application -Source "MSSQL*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message | ||
} | ||
# TODO: Figure out ISH event log source | ||
Write-Host "Probing event log for Trisoft" | ||
Get-EventLog -LogName Application -Source "Trisoft*" -After $lastCheck | Select-Object TimeGenerated, EntryType, Message | ||
|
||
$lastCheck = Get-Date | ||
Start-Sleep -Seconds 2 | ||
Write-Host "Sleeping for $intervalSeconds seconds" | ||
Start-Sleep -Seconds $intervalSeconds | ||
} | ||
} | ||
else | ||
{ | ||
Write-Host "hostname=$HostName" | ||
} |
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
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
Oops, something went wrong.