SkyWire-PSInstaller.psm1
<# .SYNOPSIS Create a complete SkyWire POS ecosystem for installing or testing a specified app .DESCRIPTION Create a complete SkyWire POS ecosystem for installing or testing a specified app .PARAMETER app The app being tested. All versions install all components, but utilize the app specified here as the central feature (valid values: POS, WebConfig, SRDM, Reporting, Gateway) .PARAMETER tag The tag (ticket number) being tested. This tag will be used as the default tag, and on every relevant name field (ex: folder names, db names, web app names, etc). .PARAMETER posTag The tag of the POS App to install. Leave blank to use the default value from the main tag. .PARAMETER wcTag The tag of the WebConfig App to install. Leave blank to use the default value from the main tag. .PARAMETER gatewayTag The tag of the Gateway App to install. Leave blank to use the default value from the main tag. .PARAMETER reportingTag The tag of the Reporting Service to install. Leave blank to use the default value from the main tag. .PARAMETER rootDir Specify the root directory where all data will reside for the current deployment (default: %TEMP%\SkyWire-PSInstaller). .PARAMETER rootSite Specify the root IIS Site where the web applications reside (default: Default Web Site). .PARAMETER dbServer The database server (default: localhost). .PARAMETER dbUser The database user id. Leave this and dbPassword blank for integrated security. .PARAMETER dbPassword The database password. Leave this and dbUser blank for integrated security. .PARAMETER posDbBacpacUrl The URL of a POS bacpac file to use as the starting db with data before applying the dacpac file for this build. .PARAMETER srdmDbBacpacUrl The URL of an SRDM bacpac file to use as the starting db with data before applying the dacpac file for this build. .PARAMETER reportingDbBacpacUrl The URL of a Reporting bacpac file to use as the starting db with data before applying the dacpac file for this build. .PARAMETER smtpUser The user for the SMTP account in WebConfig. .PARAMETER smtpPassword The password for the SMTP account in WebConfig. .PARAMETER refresh If this switch is set, it will refresh any cached files affected by the install. Useful when running subsequent tests with code changes against the same build. .PARAMETER run If this switch is set, the app specified in the app parameter will be started automatically after the install is completed. .NOTES * The POS app requires a terminal to be configured prior to running the installer. For this reason, the setup.exe file will be downloaded, but must be run manually. * All related names will use the tag as the identifier (ex: folder names, db name, app container name, etc). * By default, the database will use Trusted Connection. Provide dbUser and dbPassword if user/password need to be used. .EXAMPLE New-SWApp -app POS -tag POS-0000-beta -gatewayTag 2.4.6 -posBacpacUrl "https://mycorp.com/skywirepos.bacpac" .EXAMPLE New-SWApp -app WebConfig -tag POS-0000-beta -gatewayTag 2.4.6 -dbUser sqlUser -dbPassword myPass -run .EXAMPLE New-SWApp -app Gateway -tag 2.4.6 -posTag POS-0000-beta -wcTag POS-0000-beta -dbUser sqlUser -dbPassword myPass -run #> function New-SWApp { param( [Parameter(Mandatory=$true)] [ValidateSet("POS","WebConfig","SRDM","Reporting","Gateway")] [string] $app, [Parameter(Mandatory=$true)] [string] $tag, [Parameter(Mandatory=$false)] [string] $posTag = $tag, [Parameter(Mandatory=$false)] [string] $wcTag = $tag, [Parameter(Mandatory=$false)] [string] $gatewayTag = $tag, [Parameter(Mandatory=$false)] [string] $reportingTag = $tag, [Parameter(Mandatory=$false)] [string] $rootDir = "$env:PROGRAMDATA\SkyWire-PSInstaller", [Parameter(Mandatory=$false)] [string] $rootSite = "Default Web Site", [Parameter(Mandatory=$false)] [string] $dbServer = "localhost", [Parameter(Mandatory=$false)] [string] $dbUser = "", [Parameter(Mandatory=$false)] [string] $dbPassword = "", [Parameter(Mandatory=$false)] [string] $posBacpacUrl, [Parameter(Mandatory=$false)] [string] $srdmBacpacUrl, [Parameter(Mandatory=$false)] [string] $reportingBacpacUrl, [Parameter(Mandatory=$false)] [string] $smtpUser = "mailUser", [Parameter(Mandatory=$false)] [string] $smtpPassword = "mailPassword", [Parameter(Mandatory=$false)] [switch] $refresh, [Parameter(Mandatory=$false)] [switch] $run ) try { #Establish databases #TODO: Eventually add database name parameters, which allow users to use existing DBs rather than creating new DBs. Write-Host "Installing POS Database as $tag-POS..." -ForegroundColor Green New-SWDatabase -app "POS" -tag $wcTag -dbServer $dbServer -dbName "$tag-POS" -dbUser $dbUser -dbPassword $dbPassword -rootDir $rootDir -bacpacUrl $posBacpacUrl -force -refresh:$refresh Write-Host "Installing SRDM Database as $tag-SRDM..." -ForegroundColor Green New-SWDatabase -app "SRDM" -tag $posTag -dbServer $dbServer -dbName "$tag-SRDM" -dbUser $dbUser -dbPassword $dbPassword -rootDir $rootDir -bacpacUrl $srdmBacpacUrl -force -refresh:$refresh Write-Host "Installing Reporting Database as $tag-Reporting..." -ForegroundColor Green #New-SWDatabase -app "Reporting" -tag $reportingTag -dbServer $dbServer -dbName "$tag-Reporting" -dbUser $dbUser -dbPassword $dbPassword -rootDir $rootDir -bacpacUrl $reportingBacpacUrl -force -refresh:$refresh Write-Warning "Skipped reporting database install. This product is not yet implemented." } catch { Write-Error "An error occurred while establishing a database needed for the SkyWire POS ecosystem. Review the output of this script for additional details." } try { #Install Apps switch ($app) { "POS" { Write-Host "Installing WebConfig at $rootSite/$($tag)-WebConfig (http://localhost/$($tag)-WebConfig)... " -ForegroundColor Green New-SWWebConfig -tag $wcTag -rootDir $rootDir -rootSite $rootSite -dbServer $dbServer -dbUser $dbUser -dbPassword $dbPassword -smtpUser $smtpUser -smtpPassword $smtpPassword Write-Host "Installing SkyWire Gateway at $rootSite/$($tag)-Gateway (http://localhost/$($tag)-Gateway)... " -ForegroundColor Green New-SWGateway -tag $gatewayTag -rootSite $rootSite -rootDir $rootDir -name "$tag-Gateway" $posInstaller = New-SWPOS -tag $tag -rootDir $rootDir Write-Host "POS Installer for build $tag downloaded to $posInstaller" -ForegroundColor Green if ($run) { Invoke-Item -Path $(Split-Path $posInstaller) #& $posInstaller } } "WebConfig" { Write-Host "Installing WebConfig at $rootSite/$($tag)-WebConfig (http://localhost/$($tag)-WebConfig)... " -ForegroundColor Green New-SWWebConfig -tag $tag -rootDir $rootDir -rootSite $rootSite -dbServer $dbServer -dbUser $dbUser -dbPassword $dbPassword -smtpUser $smtpUser -smtpPassword $smtpPassword Write-Host "Installing SkyWire Gateway at $rootSite/$($tag)-Gateway (http://localhost/$($tag)-Gateway)... " -ForegroundColor Green New-SWGateway -tag $gatewayTag -rootSite $rootSite -rootDir $rootDir -name "$tag-Gateway" $posInstaller = New-SWPOS -tag $posTag -rootDir $rootDir Write-Host "POS Installer for build $posTag downloaded to $posInstaller" -ForegroundColor Green if ($run) { Start-Process -FilePath "http://localhost/$($tag)-WebConfig" } } "SRDM" { Write-Error "This app is not yet supported!" } "Reporting" { Write-Error "This app is not yet supported!" } "Gateway" { Write-Host "Installing WebConfig at $rootSite/$($tag)-WebConfig (http://localhost/$($tag)-WebConfig)... " -ForegroundColor Green New-SWWebConfig -tag $wcTag -rootDir $rootDir -rootSite $rootSite -name "$tag-WebConfig" -dbServer $dbServer -dbUser $dbUser -dbPassword $dbPassword -smtpUser $smtpUser -smtpPassword $smtpPassword Write-Host "Installing SkyWire Gateway at $rootSite/$($tag)-Gateway (http://localhost/$($tag)-Gateway)... " -ForegroundColor Green New-SWGateway -tag $tag -rootSite $rootSite -rootDir $rootDir $posInstaller = New-SWPOS -tag $posTag -rootDir $rootDir Write-Host "POS Installer for build $posTag downloaded to $posInstaller" -ForegroundColor Green if ($run) { Start-Process -FilePath "http://localhost/$($tag)-Gateway" } } } } catch { Write-Error "An error occurred while installing one or more of the apps in the the SkyWire POS ecosystem. Review the output of this script for additional details." } } |